package DateDemo;
import java.util.Calendar;
public class CalendarDemo {
public static void main(String[] args) {
Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH + 1);
int day = c.get(Calendar.DATE);
int hour = c.get(Calendar.HOUR);
int second = c.get(Calendar.SECOND);
int minute = c.get(Calendar.MINUTE);
String s = year + "年" + month + "月" + day + "日" + " " + hour + ":"
+ second + ":" + (minute > 9 ? minute : "0" + minute);
System.out.println(s);
}
}
|
|