Parse String 04/26/2010 05:39:26 GMT to Date in Java

Trying to Parse String to Date. I'm getting ParseException.
Calendar timeStamp = Calendar.getInstance(locale);// Date();
			timeStamp.setTime(DateFormat.getDateInstance().parse((String) tokenMap.get("TimeStamp")));

Open in new window

dolphin_gAsked:
Who is Participating?
 
dolphin_gConnect With a Mentor Author Commented:
Resolved it, by the below code.
Calendar timeStamp = Calendar.getInstance();// Date();
			SimpleDateFormat df = new SimpleDateFormat();
			df.applyPattern("MM/dd/yyyy hh:mm:ss z");
			timeStamp.setTime(df.parse((String) tokenMap.get("TimeStamp")));

Open in new window

0
 
basav_comCommented:
Can you print this value.
tokenMap.get("TimeStamp")

--> Seems to be some problem with this.
0
 
dolphin_gAuthor Commented:
04/26/2010 05:39:26 GMT
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
dolphin_gAuthor Commented:
java.text.ParseException: Unparseable date: "04/26/2010 05:39:26 GMT"
      java.text.DateFormat.parse(DateFormat.java:335)
0
 
basav_comCommented:
Can you print ' locale ' also ?
0
 
basav_comCommented:
Great the problem is solved :).

Helpful for others:
Need to 'format with a custom format'
http://www.exampledepot.com/egs/java.text/FormatDateLoc.html?l=rel
http://java.sun.com/j2se/1.4.2/docs/api/java/text/DateFormat.html
0
All Courses

From novice to tech pro — start learning today.