- public static String getTimeDes(long ms) {
- int ss = 1000;
- int mi = ss * 60;
- int hh = mi * 60;
- int dd = hh * 24;
- long day = ms / dd;
- long hour = (ms - day * dd) / hh;
- long minute = (ms - day * dd - hour * hh) / mi;
- long second = (ms - day * dd - hour * hh - minute * mi) / ss;
- long milliSecond = ms - day * dd - hour * hh - minute * mi - second * ss;
- StringBuilder str=new StringBuilder();
- if(day>0){
- str.append(day).append("天,");
- }
- if(hour>0){
- str.append(hour).append("小时,");
- }
- if(minute>0){
- str.append(minute).append("分钟,");
- }
- if(second>0){
- str.append(second).append("秒,");
- }
- if(milliSecond>0){
- str.append(milliSecond).append("毫秒,");
- }
- if(str.length()>0){
- str=str.deleteCharAt(str.length()-1);
- }
- return str.toString();
- }
- //该片段来自于http://www.codesnippet.cn/detail/261220138252.html
来源: http://www.codesnippet.cn/detail/261220138252.html