public class DateTest {
public static void main(String[] args) {
Calendar calendar = new GregorianCalendar();
Date trialTime = new Date();
calendar.setTime(trialTime);
//
//Class cc = Class.forName("java.util.GregorianCalendar");
//Calendar c = (GregorianCalendar)cc.newInstance();
//
System.out.println("ERA: "+calendar.get(Calendar.ERA));
//
System.out.println("YEAR: "+calendar.get(Calendar.YEAR));
// , 1
System.out.println("MONTH: "+calendar.get(Calendar.MONTH));
//
System.out.println("WEEK_OF_YEAR: "+calendar.get(Calendar.WEEK_OF_YEAR));
//
System.out.println("WEEK_OF_MONTH: "+calendar.get(Calendar.WEEK_OF_MONTH));
//
System.out.println("DATE: "+calendar.get(Calendar.DATE));
// ,
System.out.println("DAY_OF_MONTH: "+calendar.get(Calendar.DAY_OF_MONTH));
//
System.out.println("DAY_OF_YEAR: "+calendar.get(Calendar.DAY_OF_YEAR));
// ,
System.out.println("DAY_OF_WEEK: "+calendar.get(Calendar.DAY_OF_WEEK));
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss yyyy-mm-dd");
//
System.out.println(sdf.format(d));
// Date
//String s = "08:02:30 1850-02-01";
//try {
// Date str = sdf.parse(s);
//} catch (ParseException e) {
// e.printStackTrace();
//}
}
}