Skip to content

Instantly share code, notes, and snippets.

@ssaurel
Created October 9, 2017 08:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssaurel/60f60ac6b853e3511abd97cfe96f1dd0 to your computer and use it in GitHub Desktop.
Save ssaurel/60f60ac6b853e3511abd97cfe96f1dd0 to your computer and use it in GitHub Desktop.
Hexa Time method for a tutorial on the SSaurel's Blog
private String getHexaTime() {
Calendar c = Calendar.getInstance();
int h = c.get(Calendar.HOUR_OF_DAY) * 255 / 23;
int m = c.get(Calendar.MINUTE) * 255 / 59;
int s = c.get(Calendar.SECOND) * 255 / 59;
return "#" + String.format("%02X", h) + String.format("%02X", m) + String.format("%02X", s);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment