标签:
1 import java.util.Calendar; 2 3 public class Solution 4 { 5 public static void main(String[] args) 6 { 7 long totalMillis = System.currentTimeMillis(); 8 long totalSeconds = totalMillis / 1000; 9 long second = totalSeconds % 60; 10 long totalMinutes = totalSeconds / 60; 11 long minute = totalSeconds % 60; 12 long totalHours = totalMinutes / 60; 13 long hour = totalHours % 24; 14 15 Calendar calendar = Calendar.getInstance(); 16 int year = calendar.get(Calendar.YEAR); 17 int month = calendar.get(Calendar.MONTH); 18 int date = calendar.get(Calendar.DATE); 19 20 System.out.println(year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second); 21 } 22 }
标签:
原文地址:http://www.cnblogs.com/wood-python/p/5798720.html