日期:2014-05-17 浏览次数:20878 次
<script> /** * @param {} second * @return {} * @desc 秒转化成dd hh:mm:ss */ function dateFormat(second){ var dd,hh,mm,ss; second = typeof second === 'string' ? parseInt(second) : second; if(!second || second < 0){ return; } //天 dd = second / (24 * 3600) | 0; second = Math.round(second) - dd * 24 * 3600; //小时 hh = second / 3600 | 0; second = Math.round(second) - hh * 3600; //分 mm = second / 60 | 0; //秒 ss = Math.round(second) - mm * 60; if(Math.round(dd) < 10){ dd = dd > 0 ? '0' + dd : ''; } if(Math.round(hh) < 10){ hh = '0' + hh; } if(Math.round(mm) < 10){ mm = '0' + mm; } if(Math.round(ss) < 10){ ss = '0' + ss; } alert( dd + ' ' + hh + ':' + mm + ':' + ss); } </script>
------解决方案--------------------
int s,f,m; m=3600; s=m/3600; f=m%3600/60; m=m%3600%60;
------解决方案--------------------
public class test2
{
public static void main(String[] args){
double d=3600;
System.out.println("转换后的值:"+getNum(d).toString());
}
public static String getNum(double d){
double m=d/3600.00;
System.out.println(m);
String a[]=String.valueOf(m).split("\\.");
return a[0]+":"+a[1];
}
}
------解决方案--------------------
public static String second2date(long second){ long time = -3600*8 + second; GregorianCalendar gc = new GregorianCalendar(); gc.setTimeInMillis(time * 1000); String timestr = new SimpleDateFormat("HH:mm:ss").format(gc.getTime()); return timestr; }
------解决方案--------------------
public static String change(int seconds) { int temp=0; StringBuffer sb=new StringBuffer(); sb.append(seconds/3600+":"); temp=seconds%3600/60; sb.append((temp<10)?"0"+temp+":":""+temp+":"); temp=seconds%3600%60; sb.append((temp<10)?"0"+temp:""+temp); return sb.toString(); }