两个时间戳相差多长时间

好无聊……

 1 public class DateUtil {
 2     public static String getDiff(long start,long end) {
 3         int ns = 1000;//一秒多少毫秒
 4         int nm = 60 * ns;//一分钟多少毫秒
 5         int nh = 60 * nm;//一小时多少毫秒
 6         int nd = 24 * nh;//一天多少毫秒
 7         long left = end - start;
 8         int d = (int) (left / nd);//天数
 9         left = left % nd;
10         int h = (int) (left / nh);
11         left = left % nh;
12         int m = (int) (left / nm);
13         left = left % nm;
14         int s = (int) (left / ns);
15         left = left % ns;
16         return d+" d "+h+" h "+m+" m "+s+" s "+left+" ms ";
17     }
18 }

 

posted on 2015-03-27 18:26  Erbin  阅读(1035)  评论(0编辑  收藏  举报

导航