HiveBrain v1.2.0
Get Started
← Back to all entries
snippetjavaCritical

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

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
javalocaldatetimedateconvertutiltypeinto

Problem

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?

Solution

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


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

Code Snippets

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

Context

Stack Overflow Q#22929237, score: 702

Revisions (0)

No revisions yet.