Skip to main content
Post Closed as "Duplicate" by Nathan Hughes java
added 2 characters in body
Source Link
Nathan Hughes
  • 96.7k
  • 21
  • 193
  • 288

Is there a simple way to convert a LocalDate (introduced with Java 8) to java.util.Date object?
By

By 'simple', I mean simpler than this:

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

which seems a bit awkward to me.

Since we are interested only in the date portion and there is no timezone information in neither of the objects, why introduce time zones explicitly? The midnight time and the system default timezone should be taken implicitly for the 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:

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

which seems a bit awkward to me.

Since we are interested only in the date portion and there is no timezone information in neither of the objects, why introduce time zones explicitly? The midnight time and the system default timezone should be taken implicitly for the 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:

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

which seems a bit awkward to me.

Since we are interested only in the date portion and there is no timezone information in neither of the objects, why introduce time zones explicitly? The midnight time and the system default timezone should be taken implicitly for the conversion.

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

edited title
Link
George
  • 7.7k
  • 8
  • 37
  • 49

Simpliest LocalDate to java.util.Date conversion and vice versa simpliest conversion?

Rollback to Revision 8
Link
George
  • 7.7k
  • 8
  • 37
  • 49
Loading
edited title
Link
George
  • 7.7k
  • 8
  • 37
  • 49
Loading
added 7 characters in body; edited title
Source Link
Tunaki
  • 138.2k
  • 46
  • 370
  • 443
Loading
edited title
Link
George
  • 7.7k
  • 8
  • 37
  • 49
Loading
added 1 character in body
Source Link
George
  • 7.7k
  • 8
  • 37
  • 49
Loading
edited body
Source Link
George
  • 7.7k
  • 8
  • 37
  • 49
Loading
edited body
Source Link
George
  • 7.7k
  • 8
  • 37
  • 49
Loading
Rollback to Revision 1
Source Link
George
  • 7.7k
  • 8
  • 37
  • 49
Loading
added 1 character in body
Source Link
George
  • 7.7k
  • 8
  • 37
  • 49
Loading
Source Link
George
  • 7.7k
  • 8
  • 37
  • 49
Loading