An OffsetDateTime is just a date time with an offset from UTC.
So if you have a fixed offset (e.g. +02 from UTC), you can convert the localDateTime like this :
OffsetDateTime.of(localDateTime, ZoneOffset.of("+2"));
OffsetDateTime.of(localDateTime, ZoneOffset.of("+02"));
OffsetDateTime.of(localDateTime, ZoneOffset.of("+02:00"));
Most of the time you want to have the offset of a specific timezone, in this case it would be preferable to use a ZonedDateTime
because for most timezone the offset is not the same in summer/winter and ZonedDateTime
will automatically handle it for you.
If you absolutely want an OffsetDateTime
with an offset from a specific timezone, you can write :
localDateTime.atZone(ZoneId.of("Europe/Paris")).toOffsetDateTime();