Possible Duplicate:
format date from 14 aug to YYYYMMDD
Hi I need to get a date in a YYYYMMDD format. I Don’t know the right method for that…
I set the date with this lines of code…
Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month);
cal.set(Calendar.DATE, date);
Later in the code I need to extract the YYYYMMDD date value, how I can do that?
Thanks
You would use
SimpleDateFormat:Personally I would strongly recommend that you look at using Joda Time instead though – it’s a much nicer API than the built-in
Date/Calendarclass.