Change the date 14 aug 2011 to the format 20110814 .. how can i do that in java ?
Here 14aug is a string ... String date="14aug";
See Question&Answers more detail:osChange the date 14 aug 2011 to the format 20110814 .. how can i do that in java ?
Here 14aug is a string ... String date="14aug";
See Question&Answers more detail:osSimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
String yyyyMMdd = sdf.format(date);
Reference: java.text.SimpleDateFormat
Update: the question by The Elite Gentleman is important. If you start with a String
, then you should first parse it to obtain the date
object from the above example:
Date date = new SimpleDateFormat("dd MMM yyyy").parse(dateString);