Alex Rivera | Logout

How to convert a date String to a Date or Calendar object?

Asked 2008-09-04T13:54:17.683
63

I have a String representation of a date that I need to create a Date or Calendar object from. I've looked through Date and Calendar APIs but haven't found anything that can do this other than creating my own ugly parse method. I know there must be a way, does anyone know of a solution?

Edit
Report

1 Answer

8

The highly regarded Joda Time library is also worth a look. This is basis for the new date and time api that is pencilled in for Java 7. The design is neat, intuitive, well documented and avoids a lot of the clumsiness of the original java.util.Date / java.util.Calendar classes.

Joda's DateFormatter can parse a String to a Joda DateTime.

answered 2008-09-04T15:28:11.483

Your Answer