Created
October 7, 2017 16:53
-
-
Save Tarelochkin/57296cf655011de21a21d31d39490464 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<string name="countDownFormat" >%1$02d:%2$02d</string> | |
<string name="timeFormat">hh:mm a</string> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//process current time in milliseconds into "00:00 am" format | |
Timestamp currentTime = new Timestamp(System.currentTimeMillis()); | |
SimpleDateFormat formatter = new SimpleDateFormat(getString(R.string.timeFormat), Locale.getDefault()); | |
String currentTimeString = formatter.format(currentTime); | |
//process a number of minutes into "hh:mm" format | |
long totalMinutesCount = 123; | |
long hoursCount = TimeUnit.MINUTES.toHours(totalMinutesCount); | |
long minutesLessHoursCount = | |
totalMinutesCount - TimeUnit.HOURS.toMinutes(hoursCount); | |
//will produce "02:03" | |
String hoursAndMinutesCount = getString(R.string.countDownFormat, | |
hoursCount, | |
minutesLessHoursCount); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment