1package com.roytuts.time;
2import java.util.concurrent.TimeUnit;
3public class MillisToDayHrMinSec {
4 public static void main(String[] args) {
5 final long milliseconds = 5478965412358l;
6 final long dy = TimeUnit.MILLISECONDS.toDays(milliseconds);
7 final long hr = TimeUnit.MILLISECONDS.toHours(milliseconds)
8 - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(milliseconds));
9 final long min = TimeUnit.MILLISECONDS.toMinutes(milliseconds)
10 - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(milliseconds));
11 final long sec = TimeUnit.MILLISECONDS.toSeconds(milliseconds)
12 - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(milliseconds));
13 final long ms = TimeUnit.MILLISECONDS.toMillis(milliseconds)
14 - TimeUnit.SECONDS.toMillis(TimeUnit.MILLISECONDS.toSeconds(milliseconds));
15 System.out
16 .println(String.format("%d Days %d Hours %d Minutes %d Seconds %d Milliseconds", dy, hr, min, sec, ms));
17 }
18}