clankill3r clankill3r - 1 year ago 147
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
Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download