import java.text.SimpleDateFormat;
import java.util.Date;
public class StringtoDate {
public static void main (String args[]){
String inputDate = "04.11.2013 11:14:45 GMT 00:00";
Date dat = convertStringToDate(inputDate);
}
public static Date convertStringToDate(String inDate){
SimpleDateFormat sdf = new SimpleDateFormat("mm.dd.yyyy hh24:mm:ss");
Date date = new Date();
try {
date = sdf.parse(inDate);
} catch (Exception e) {
e.printStackTrace();
}
return date;
}
}
my input String is of type String ("04.11.2013 11:14:45 GMT 00:00"),
I m trying to convert to a type Date and which should be of foramt ("mm.dd.yyyy hh24:mi:ss") , and output of the DAte should look like ("3/7/2013 12:33:15.000000000 PM").
but i m getting exception ,
java.text.ParseException: Unparseable date: "04.11.2013 11:14:45 GMT 00:00"
at StringtoDate.convertStringToDate(StringtoDate.java:14)
at StringtoDate.main(StringtoDate.java:8)
please help me to get the correct results.