Joda time : convert string to LocatDate

Posted by bsreekanth on Stack Overflow See other posts from Stack Overflow or by bsreekanth
Published on 2010-04-27T13:32:46Z Indexed on 2010/04/27 13:33 UTC
Read the original article Hit count: 597

Filed under:

Hello, How to specify the format string to convert the date alone from string. In my case, only the date part is relevant

Constructing it as DateTime fails

String dateString = "2009-04-17";
DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd");
DateTime dateTime = formatter.parseDateTime(dateString);

with error java.lang.IllegalArgumentException: Invalid format: "2011-04-17" is too short

Probably because I should use LocalTime instead. But, I do not see any formatter for LocalTime . What is the best way to convert String dateString = "2009-04-17"; into LocalDate (or something else if that is not the right representation)

thanks...

© Stack Overflow or respective owner

Related posts about jodatime