1

I am getting date as "04/26/2013" and time as "05:30 AM "and time zone as"-12.0" from the jsp page and getting it in a servlet how can I convert this String values in to java.util.Date format . I have tried to append the Strings and got (04/26/2013 05:30 AM -12.0) but am not able to use Dateformat or timestamp

Can anyone suggest a way to solve this ?

Maroun
  • 94,125
  • 30
  • 188
  • 241
  • 1
    I think you haven't done your search, look here : [1]: http://stackoverflow.com/questions/4216745/java-string-to-date-conversion [2]: http://stackoverflow.com/questions/6510724/how-to-convert-java-string-to-date-object [3]: http://stackoverflow.com/questions/2735023/convert-string-to-java-util-date – user1155391 Apr 17 '13 at 10:22
  • this is the String value **04/26/2013 05:30 AM GMT-12.0** but it is showing the error **unparseable date** –  Apr 17 '13 at 10:35

1 Answers1

0

I think it comes from the time zone format.

DateFormat df = new SimpleDateFormat("dd/MM/yyy hh:mm a Z");
String t = "04/26/2013 05:30 AM -1200";
String tt = "04/26/2013 05:30 AM GMT -1200";
Date d= df.parse(t);
Date d= df.parse(tt);

works for me.

You can read more about time zone format here

phoenix7360
  • 2,807
  • 6
  • 30
  • 41