转自:http://blog.csdn.net/sunshinestation/article/details/4568946
将毫秒数或两个日期类型数转换为*天*小时*分*秒的方法,在进行时间段计算时应该经常用到。
-
- public
static String formatDuring(long mss) { -
long days = mss / (1000 * 60 * 60 * 24); -
long hours = (mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60); -
long minutes = (mss % (1000 * 60 * 60)) / (1000 * 60); -
long seconds = (mss % (1000 * 60)) / 1000; -
return days + " days " + hours + " hours " + minutes + " minutes " -
+ seconds + " seconds "; - }
-
- public
static String formatDuring(Date begin, Date end) { -
return formatDuring(end.getTime() - begin.getTime()); - }
希望大家有用。