How to convert Joda LocalDate to java.util.Date?

date, java, jodatime

Solution

JodaTime

To convert JodaTime's `org.joda.time.LocalDate` to `java.util.Date`, do

Date date = localDate.toDateTimeAtStartOfDay().toDate();

To convert JodaTime's `org.joda.time.LocalDateTime` to `java.util.Date`, do

Date date = localDateTime.toDate();

JavaTime

To convert Java8's `java.time.LocalDate` to `java.util.Date`, do

Date date = Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());

To convert Java8's `java.time.LocalDateTime` to `java.util.Date`, do

Date date = Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());

You might be tempted to shorten it with `LocalDateTime#toInstant(ZoneOffset)`, but there isn't a direct API to obtain the system default zone offset.

To convert Java8's `java.time.ZonedDateTime` to `java.util.Date`, do

Date date = Date.from(zonedDateTime.toInstant());

Problem

What is the simplest way to convert a JodaTime `LocalDate` to `java.util.Date` object?

Original source