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

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

Question by:dolphin_g
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
LVL 12

Expert Comment

ID: 24063175
Can you print this value.

--> Seems to be some problem with this.

Author Comment

ID: 24063190
04/26/2010 05:39:26 GMT

Author Comment

ID: 24063216
java.text.ParseException: Unparseable date: "04/26/2010 05:39:26 GMT"
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!

LVL 12

Expert Comment

ID: 24063325
Can you print ' locale ' also ?

Accepted Solution

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

LVL 12

Expert Comment

ID: 24063409
Great the problem is solved :).

Helpful for others:
Need to 'format with a custom format'

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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 will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This video teaches viewers about errors in exception handling.
Suggested Courses

628 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