/** * 将秒数转换成天具体的天时分秒 * 比如172800S转换成2天0时0分0秒 * @param second * @return */public String formatSecond(Object second){ String timeStr = "0秒"; if(second!=null){ Double s=(Double) second; String format; Object[] array; Integer days = (int)(s /(60 * 60 * 24)); Integer hours =(int)(s/(60*60) - days * 24); Integer minutes = (int)(s/60 - hours*60 - days * 24 * 60); Integer seconds = (int)(s-minutes*60-hours*60*60 - days * 24 * 60 * 60); if(days>0){ format="%1$,d天%2$,d时%3$,d分%4$,d秒"; array=new Object[]{days,hours,minutes,seconds}; } else if(hours>0){ format="%1$,d时%2$,d分%3$,d秒"; array=new Object[]{hours,minutes,seconds}; }else if(minutes>0){ format="%1$,d分%2$,d秒"; array=new Object[]{minutes,seconds}; }else{ format="%1$,d秒"; array=new Object[]{seconds}; } timeStr = String.format(format, array); } return timeStr ;}