How to convert Instant not stored in UTC to UTC?

1.1k views Asked by At

I'm getting an Instant from DB1, that is supposed to be in UTC, and putting it in DB2. But the instant I'm getting is in DB1 local time. I have their timezone(ZoneId) but I can't figure out how to convert it to UTC before putting it in DB2

1

There are 1 answers

2
Louis Wasserman On

An Instant is always in UTC, and never needs timezone conversion. If you tried to convert an Instant to an Instant in another timezone correctly, you would always get exactly the same Instant back.

What you must have is a bug in how it's being stored, or how it's being displayed.