File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Android Security Essentials Live Lessons this week in the Android 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
 
jQuery in Action, 2nd edition
 
subject: convert the String value into java.util.Date
 
Similar Threads
conversion of date
Convert Java.sql.Date to String or Java.util.Date
Sorting Jtables with dates
Date format
Date formatting