Solved

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

Posted on 2009-04-03
7
303 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
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!

 
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

Technology Partners: 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

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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
The viewer will learn how to implement Singleton Design Pattern in Java.

734 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