Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2009-04-03
7
Medium Priority
?
312 Views
Last Modified: 2013-12-29
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

0
Comment
Question by:dolphin_g
  • 3
  • 3
7 Comments
 
LVL 12

Expert Comment

by:basav_com
ID: 24063175
Can you print this value.
tokenMap.get("TimeStamp")

--> Seems to be some problem with this.
0
 

Author Comment

by:dolphin_g
ID: 24063190
04/26/2010 05:39:26 GMT
0
 

Author Comment

by:dolphin_g
ID: 24063216
java.text.ParseException: Unparseable date: "04/26/2010 05:39:26 GMT"
      java.text.DateFormat.parse(DateFormat.java:335)
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 12

Expert Comment

by:basav_com
ID: 24063325
Can you print ' locale ' also ?
0
 

Accepted Solution

by:
dolphin_g earned 0 total points
ID: 24063391
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
 
LVL 12

Expert Comment

by:basav_com
ID: 24063409
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question