Java 數轉換為標準時間
阿新 • • 發佈:2018-12-10
//s數轉換為標準時間 public static String formatDateTime(String DateSelect,long seconds) { int startHours = (int) (seconds/3600); int startMinutes = (int) ((seconds%3600)/60); int startSeconds = (int) ((seconds%3600)%60); Calendar cal=Calendar.getInstance();//使用日曆類 //時間:yyyy-MM-dd HH:mm:ss String startDateStr = DateSelect + " " + startHours + ":" + startMinutes + ":" + startSeconds; System.out.println("時間:" + startDateStr);
return startDateStr; }