Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java 8 - Convert LocalDate to OffsetDateTime

I like to know if it is possible to convert in Java 8 from LocalDate to OffsetDateTime.

For example assume that I have got this LocalDate:

1992-12-28

Then I would like to have it converted to this OffsetDateTime:

1992-12-28T00:00-03:00

Assume that we know the time zone, for example America/Santiago.

like image 638
Sandro Rey Avatar asked Jul 26 '19 06:07

Sandro Rey


1 Answers

You can try this..

OffsetDateTime o = OffsetDateTime.of(LocalDate.now(),LocalTime.NOON, ZoneOffset.UTC);
OffsetDateTime o1 = OffsetDateTime.of(LocalDateTime.now(), ZoneOffset.UTC);
like image 162
Rowi Avatar answered Dec 07 '22 22:12

Rowi