Friday, June 13, 2008

Formatting date in java

To format a date in java

Calendar cal = Calendar.getInstance();

String myDate = new SimpleDateFormat("ddMMMyyyy").format(cal.getTime());

Similarly we can use a string to convert to Date

Date myOtherDate = new SimpleDateFormat("ddMMMyyyy").parse(dateString);

No comments: