package ;
import ;
import ;
import ;
import ;
public class DateTest {
public static void main(String[] args) throws ParseException {
Calendar now = ();
("Year: " + ());
("Moon: " + (() + 1) + "");
("Day: " + (Calendar.DAY_OF_MONTH));
("Time: " + (Calendar.HOUR_OF_DAY));
("Score: " + ());
("Second: " + ());
("Current time milliseconds:" + ());
(());
Date d = new Date();
(d);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateNowStr = (d);
("Formatted date:" + dateNowStr);
String str = "2012-1-13 17:26:33"; //It should be the same as the format defined by sdf above
Date today = (str);
("Stand to date:" + today);
}
}
Output result:
Year: 2012
Month: 1
Day: 13
At: 17
Points: 28
Seconds: 19
Current time milliseconds: 1326446899902
Fri Jan 13 17:28:19 CST 2012
Fri Jan 13 17:28:19 CST 2012
Formatted date: 2012-01-13 17:28:19
String conversion date: Fri Jan 13 17:26:33 CST 2012