my dog learned polymorphism*
The moose likes Beginning Java and the fly likes convert String to Date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "convert String to Date" Watch "convert String to Date" New topic

convert String to Date

Peter Guillebaud
Ranch Hand

Joined: Jul 11, 2001
Posts: 57
Does anyone know how to do this for multiple dates if the date Strings are of variable lengths? I think the SimpleDateFormat class should help but how can it be done when one date String is August 31, 2001 14:00 GMT and another September 18, 2001 23:00 GMT ? The format is the same but the number of letters for each month changes!! I need to change it to format yyyy-mm-dd.
Thanks in advance.

Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
The length doesn't matter you tell it what format the String is in and the parse method takes care of the details.
Chad McGowan
Ranch Hand

Joined: May 10, 2001
Posts: 265
use this SimpleDateFormat string
Peter Guillebaud
Ranch Hand

Joined: Jul 11, 2001
Posts: 57
Thanks very much, that works perfectly.
I agree. Here's the link:
subject: convert String to Date
Similar Threads
millenium bug returns!
Java Date formatting problem
Convert String value to Date Object
How do i format a string to date
Date(long date)