Skip to content

Instantly share code, notes, and snippets.

@sdanna
Created October 21, 2015 21:27
Show Gist options
  • Save sdanna/503e2c6b5c3a111332b3 to your computer and use it in GitHub Desktop.
Save sdanna/503e2c6b5c3a111332b3 to your computer and use it in GitHub Desktop.
Helper Functions for Time formatting
private String getAmPm(int hourOfDay) {
return (hourOfDay >= 12) ? "PM" : "AM";
}
private int get12HourFormat(int hourOfDay) {
if (hourOfDay == 0) return 12;
return (hourOfDay <= 12) ? hourOfDay : hourOfDay - 12;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment