Software Development

Convert String to LocalDate in JodaTime and Java 8

Handling dates (and time) is never easy and time-consuming. Moreover, its support by Java has been inadequate. If you find yourself longing for some libraries to ease the pain, go ahead because you are not alone. For pre-Java 8, one of the best options is JodaTime. Then came Java 8 with java.time API, a project that has been led jointly by the author of Joda-Time (Stephen Colebourne) and Oracle, under JSR 310.

For more details, please read Java SE 8 Date and Time by Ben Evans and Richard Warburton.

Back to the topic. Here are ways how to convert a date string in a particular format to a LocalDate object.

Using JodaTime

Using Java 8 java.time API

Note that you still need to include any JodaTime dependencies unless you are using Java 8 all the way.


Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.

You Might Also Like