Convert java.sql.Timestamp to java.time.OffsetDateTime

Hard to believe but I think this is the simplest you can manage:

long millisSinceEpoch = timestamp.getTime();
Instant instant = Instant.ofEpochMilli(millisSinceEpoch)
OffsetDateTime dt = OffsetDateTime.ofInstant(instant, ZoneId.of("UTC"))


One Reply to “Convert java.sql.Timestamp to java.time.OffsetDateTime”

Leave a Reply

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.