How to convert LocalDateTime to OffsetDateTime?
There are many ways to convert LocalDateTime to OffsetDateTime. Some of them are listed below: 1. Using LocalDateTime#atOffset(ZoneOffset offset): LocalDateTime ldt = LocalDateTime.now(); ZoneOffset offset = ZoneOffset.UTC; OffsetDateTime odt = ldt.atOffset(offset); 2. Using LocalDateTime#atZone(ZoneId zone) => ZonedDateTime#toOffsetDateTime(): LocalDateTime ldt = LocalDateTime.now(); // Change the ZoneId as required e.g. ZoneId.of(“Europe/London”) ZoneId zoneId = ZoneId.systemDefault(); OffsetDateTime odt … Read more