Java, Software Development

Java – Convert LocalDateTime to OffsetDateTime

This post is about how to convert LocalDateTime to OffsetDateTime at the current zone offset.

Append with Zone Offset

Basically, we want to append a LocalDateTime object with the current zone offset without converting it first to string object (to concatenate it with +/-##:##) and then to an OffsetDateTime object. We just want the zone offset based on where we execute the codes.

Codes

Testing

You Might Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *