This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
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 Head First Android this week in the Android 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.
It is sorta covered in the JavaRanch Style Guide.
subject: convert String to Date
It's not a secret anymore!