Commit b50bb0c9 by huangfusuper

修正邮箱日志显示的执行时间不正确BUG

parent c5120beb
...@@ -13,23 +13,35 @@ public class TimeFormatUtil { ...@@ -13,23 +13,35 @@ public class TimeFormatUtil {
* @return * @return
*/ */
public static String timeFormat(long time) { public static String timeFormat(long time) {
//秒 StringBuffer sb=new StringBuffer();
long seconds = TimeUnit.MILLISECONDS.toSeconds(time); long millis=1;
long minutes = TimeUnit.MILLISECONDS.toMinutes(time); long seconds=1000*millis;
long hours = TimeUnit.MILLISECONDS.toHours(time); long minutes=60*seconds;
//小时 long hours=60*minutes;
if(hours > 0){ long days=24*hours;
return hours + "小时"; if(time/days>=1){
//分钟 sb.append((int)(time/days)+"天");
} if (minutes > 0) {
return minutes + "分钟";
//秒
} else if (seconds > 0) {
return seconds + "秒";
//毫秒
} else{
return time+"毫秒";
} }
if(time%days/hours>=1){
sb.append((int)(time%days/hours)+"小时");
}
if(time%days%hours/minutes>=1){
sb.append((int)(time%days%hours/minutes)+"分钟");
}
if(time%days%hours%minutes/seconds>=1){
sb.append((int)(time%days%hours%minutes/seconds)+"秒");
}
if(time%days%hours%minutes%seconds/millis>=1){
sb.append((int)(time%days%hours%minutes%seconds/millis)+"毫秒");
}
return sb.toString();
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment