I have checked this site and the web for a solution but with no result. I have been looking all over the web for a solution to my date format problem. I have a string that I want to convert into a date format as follows:
yyyyMMdd-HH:mm:ss.SSS
My code is:
String myTestString = "20111215-07:26:48.689";
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HH:mm:ss.SSS", Locale.ENGLISH);
Date d = null;
try{
d = sdf.parse(myTestString);
System.out.println(d);
}catch(ParseException pe){
pe.printStackTrace();
}
But I get:
java.text.ParseException: Unparseable date: "Fri Dec 16 15:48:42 GMT 2011"
at java.text.DateFormat.parse(DateFormat.java:337)
at TestClass.main(TestClass.java:54)
Any ideas?