Skip to content

Instantly share code, notes, and snippets.

@Paulius11
Created April 10, 2020 04:12
Show Gist options
  • Save Paulius11/9bfd3a46ba59696c33bdda591594d55a to your computer and use it in GitHub Desktop.
Save Paulius11/9bfd3a46ba59696c33bdda591594d55a to your computer and use it in GitHub Desktop.
java snippet
#Random
## Secure random generating
private static final int NUMBER_OF_CARDS = 52;
private static final SecureRandom randomNumbers = new SecureRandom();
int second = randomNumbers.nextInt(NUMBER_OF_CARDS)
#Printing
##Printing values with leading zeros 0:
System.out.printf("valu:e %s%n", counter );
String.format("%02d:%02d:%02d", hour, minute, second);
String.format("%d:%02d:%02d %s", ((hour == 0 || hour == 12) ? 12 : hour % 12), minute, second, (hour < 12 ? "AM" : "PM"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment