jQuery in Action, 2nd edition
The moose likes Beginning Java and the fly likes Convert String value to Date Object Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Convert String value to Date Object" Watch "Convert String value to Date Object" New topic
Author

Convert String value to Date Object

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Hi Folks,

How to convert a String "Wed Oct 15 00:00:00 GMT+05:30 2008" to Date [by using format or any other way ] ?. i tried using SimpleDateFormat but failed
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Then you haven't used the right pattern. Which one did you use?


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Sorry for the late reply

this is my code:



the Exception is : java.text.ParseException: Unparseable date: "Wed Oct 15 00:00:00 GMT+05:30 2008"

thanks
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Ahh , sily mistake! [Problem Solved]

this is right pattern.



thanks Rob
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

You're welcome. I know that sometimes you can find solutions yourself just by sharing the problem.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Convert String value to Date Object
 
Similar Threads
Formatting the String
Help in converting date from string
Date Format
convert a string to date whitout format
convert date format