Last active
August 29, 2015 14:16
-
-
Save seventhmoon/4c255aff0e0e657e9dbd to your computer and use it in GitHub Desktop.
TimeConverter
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
public class TimeHelper{ | |
public static final SimpleDateFormat HMS_DATE_FORMAT = new SimpleDateFormat("hh:mm:ss"); | |
public static long toMillis(int hour, int minute, int second){ | |
return toSeconds(hour, minute, second) * 1000; | |
} | |
public static long toSeconds(int hour, int minute, int second){ | |
return (hour * 3600 + minute * 60 + second); | |
} | |
public static String formatDurationHMS(long millis){ | |
GregorianCalendar c = new java.util.GregorianCalendar(); | |
c.setTimeInMillis(mills); | |
return HMS_DATE_FORMAT.format(c.getTime()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment