This week's giveaway is in the Groovy forum.
We're giving away four copies of Groovy Fundamentals video training course and have Ken Kousen on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes convert the String value into java.util.Date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Groovy Fundamentals video training course this week in the Groovy forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "convert the String value into java.util.Date " Watch "convert the String value into java.util.Date " New topic
Author

convert the String value into java.util.Date

kan ashok
Greenhorn

Joined: Feb 28, 2004
Posts: 8
How can i convert the String value into java.util.Date ?
I tried thru the following way :
String hai = "20/03/2004"; // mm/dd/yyyy
Date cdate = new SimpleDateFormat("mm/dd/yyyy").parse(hai);
It gives wrong Month.
Carlos Failde
Ranch Hand

Joined: Oct 20, 2000
Posts: 84
From the API:
A month is represented by an integer from 0 to 11; 0 is January, 1 is February, and so forth; thus 11 is December
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

Try look at your code!!

Witch month has the number '20'?
And the pattern for a month is MM. SimpleDateFormat
Ren´┐Ż


Regards, Rene Larsen
Dropbox Invite
 
wood burning stoves
 
subject: convert the String value into java.util.Date