clankill3r clankill3r - 8 months ago 58
Java Question

String to LocalDate

How can i convert a string to a


I have seen examples like:

LocalDate dt = new LocalDate("2005-11-12");

But my strings are like:


fge fge

As you use Joda Time, you should use DateTimeFormatter:

final DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyy-MMM-dd");
final LocalDate dt = dtf.parseLocalDate(yourinput);

If using Java 8 or later, then refer to hertzi's answer