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

Posted on 2009-04-03
Medium Priority
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"
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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 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…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

718 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