2016年8月11日 星期四

How to change the second to hour minute day ?

29 How to change the second to hour minute day ?

use time unit


long uptime = System.currentTimeMillis();

                           long days = TimeUnit.MILLISECONDS
                                   .toDays(uptime);
                           uptime -= TimeUnit.DAYS.toMillis(days);

                           long hours = TimeUnit.MILLISECONDS
                                   .toHours(uptime);
                           uptime -= TimeUnit.HOURS.toMillis(hours);

                           long minutes = TimeUnit.MILLISECONDS
                                   .toMinutes(uptime);
                           uptime -= TimeUnit.MINUTES.toMillis(minutes);

                           long seconds = TimeUnit.MILLISECONDS
                                   .toSeconds(uptime);