I'm doing a countdown timer, I got rid of int variable and made long. The following methods how I get hours, minutes and seconds.
public static long getHours(long totalSeconds) {
return (long) Math.floor(totalSeconds / 3600000);
}
public static long getMinutes(long totalSeconds) {
return (long) Math.floor((totalSeconds - 3600000 * getHours(totalSeconds)) / 60000);
}
public static long getSeconds(long totalSeconds) {
return (long) Math.floor(totalSeconds - 3600000 * getHours(totalSeconds) - 60000 * getMinutes(totalSeconds));
}
public static long getMilliseconds(long totalSeconds) {
return (long) Math.floor(getSeconds(totalSeconds) / 1000);
}
For ms I divided the second by 1000. Now I get time in such format 12:34:56.000. In place of milliseconds are always .000
What is wrong? How to get milliseconds?