I have this value,
2011-11-19T00:00:00.000-03:00
which needs to be converted and set it in this format
yyyyMMdd
I tried this way
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public class ParsedDate {
public static void main(String args[]) throws ParseException {
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ",
Locale.US);
String s1 = "2011-11-19T00:00:00.000-03:00";
Date d = sdf.parse(s1);
String s2 = (new SimpleDateFormat("yyyyMMdd")).format(d);
System.out.println(s2);
}
}
But it is giving me
Exception in thread "main" java.text.ParseException: Unparseable date: "2011-11-19T00:00:00.000-03:00"
Could anybody please help me?