I want to parse a date in YYYY-MM-DD format to YYYYMMDD. If I use the following function, it returns me a YYYYMMDD format but with a d
A SimpleDateFormat should be capable of achieving what you're after. Be very careful with the format marks, D and d mean different things
String oldDateString = "2013-05-16";
System.out.println(oldDateString );
Date date = new SimpleDateFormat("yyyy-MM-dd").parse(oldDateString);
System.out.println(date);
String newDateString = new SimpleDateFormat("yyyyMMdd").format(date);
System.out.println(newDateString);
(Also, beware of Y and y :P)
This outputs
2013-05-16
Thu May 16 00:00:00 EST 2013
20130516
For me...