public class ChangeTime {
public static void main(String[] args) {
//時間總的秒數
int seconds = 30654;
//開始時間
int startHours = seconds/3600;
int startMinutes = (seconds%3600)/60;
int startSeconds = (seconds%3600)%60;
Calendar cal=Calendar.getInstance();//使用日曆類
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//時間格式
//時間:yyyy-MM-dd HH:mm:ss
String startDateStr = cal.get(Calendar.YEAR) + "-" + (cal.get(Calendar.MONTH)+1)
+ "-" + cal.get(Calendar.DAY_OF_MONTH) + " " + startHours
+ ":" + startMinutes + ":" + startSeconds;
System.out.println("時間:" + startDateStr);
}
public class ChangeTime {
public static void main(String[] args) {
//時間總的秒數
int seconds = 30654;
//開始時間
int startHours = seconds/3600;
int startMinutes = (seconds%3600)/60;
int startSeconds = (seconds%3600)%60;
Calendar cal=Calendar.getInstance();//使用日曆類
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//時間格式
//時間:yyyy-MM-dd HH:mm:ss
String startDateStr = cal.get(Calendar.YEAR) + "-" + (cal.get(Calendar.MONTH)+1)
+ "-" + cal.get(Calendar.DAY_OF_MONTH) + " " + startHours
+ ":" + startMinutes + ":" + startSeconds;
System.out.println("時間:" + startDateStr);
}