Solved

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

Posted on 2009-04-03
7
301 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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
 
LVL 92

Expert Comment

by:objects
ID: 24064211
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

730 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