Posted By

hariharank12 on 12/01/10


Tagged

gregorianCalendar javaGregorianCalendar javaCalendar calendarJava


Versions (?)

Java GregorianCalendar


 / Published in: Java
 

  1. Calendar calendar = new GregorianCalendar(pdt);
  2. Date trialTime = new Date();
  3. calendar.setTime(trialTime);
  4.  
  5. // print out a bunch of interesting things
  6. System.out.println("ERA: " + calendar.get(Calendar.ERA));
  7. System.out.println("YEAR: " + calendar.get(Calendar.YEAR));
  8. System.out.println("MONTH: " + calendar.get(Calendar.MONTH));
  9. System.out.println("WEEK_OF_YEAR: " + calendar.get(Calendar.WEEK_OF_YEAR));
  10. System.out.println("WEEK_OF_MONTH: " + calendar.get(Calendar.WEEK_OF_MONTH));
  11. System.out.println("DATE: " + calendar.get(Calendar.DATE));
  12. System.out.println("DAY_OF_MONTH: " + calendar.get(Calendar.DAY_OF_MONTH));
  13. System.out.println("DAY_OF_YEAR: " + calendar.get(Calendar.DAY_OF_YEAR));
  14. System.out.println("DAY_OF_WEEK: " + calendar.get(Calendar.DAY_OF_WEEK));
  15. System.out.println("DAY_OF_WEEK_IN_MONTH: "
  16. + calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH));
  17. System.out.println("AM_PM: " + calendar.get(Calendar.AM_PM));
  18. System.out.println("HOUR: " + calendar.get(Calendar.HOUR));
  19. System.out.println("HOUR_OF_DAY: " + calendar.get(Calendar.HOUR_OF_DAY));
  20. System.out.println("MINUTE: " + calendar.get(Calendar.MINUTE));
  21. System.out.println("SECOND: " + calendar.get(Calendar.SECOND));
  22. System.out.println("MILLISECOND: " + calendar.get(Calendar.MILLISECOND));
  23. System.out.println("ZONE_OFFSET: "
  24. + (calendar.get(Calendar.ZONE_OFFSET)/(60*60*1000)));
  25. System.out.println("DST_OFFSET: "
  26. + (calendar.get(Calendar.DST_OFFSET)/(60*60*1000)));

Report this snippet  

You need to login to post a comment.