Calendar Java Date Format
The java util calendar set int year int month int date method sets the values for the calendar fields year month and day of month.
Calendar java date format. Calendar calendar calendar getinstance. Java date format example. In java you can use calendar settime date to convert a date object to a calendar object.
String date dateformat format new date. Calendar set 1969 calendar august 15 17 35 27. Use java util calendar class if you need to extract year month day hour minute and second or manipulating these field e g 7 days later 3 weeks earlier.
Few examples to work with calendar apis. Date newdate calendar settime date. There are two classes for formatting date in java.
You could use simpledateformat to control the date time display format. Java text format is the parent class and java text simpledateformat is the subclass of java. Dateformat dateformat dateformat getdateinstance dateformat default locale.
Simpledateformat sdf new simpledateformat yyyy mmm dd hh mm ss. The java text dateformat class provides various methods to format and parse date and time in java in language independent manner. Dateformat class has a format method which is responsible for formatting.
The dateformat class is an abstract class. 2013 jan 31 00 00 00 example 2 2 simple calendar example. You can format the calender date object when you want to display and keep that as a string.