Convert java.time.LocalDate into java.util.Date type

Kavinda Gehan picture Kavinda Gehan · Apr 8, 2014 · Viewed 386.1k times · Source

I want to convert java.time.LocalDate into java.util.Date type. Because I want to set the date into JDateChooser. Or is there any date chooser that supports java.time dates?

Answer

JB Nizet picture JB Nizet · Apr 8, 2014
Date date = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());

That assumes your date chooser uses the system default timezone to transform dates into strings.