Convert java.util.Date to java.time.LocalDate

What is the best way to convert a java.util.Date object to the new JDK 8/JSR-310 java.time.LocalDate? Date input = new Date(); LocalDate date = ??? 13 s 13 Short answer Date input = new Date(); LocalDate date = input.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); Explanation Despite its name, java.util.Date represents an instant on the time-line, not a “date”. The actual … Read more

LocalDate to java.util.Date and vice versa simplest conversion?

Is there a simple way to convert a LocalDate (introduced with Java 8) to java.util.Date object? By ‘simple’, I mean simpler than this Nope. You did it properly, and as concisely as possible. java.util.Date.from( // Convert from modern java.time class to troublesome old legacy class. DO NOT DO THIS unless you must, to inter operate … Read more