Before I'll start - I've looked at those answers and didn't got the required answer:
I've currently read from a database 2 column:
- created_at (a timestamp in which this column was created - for example,
2016-12-23 15:39:15
) - timezone - the timezone of the timestamp (for example -
GMT+01:00
).
I need to convert this information into an RFC 3999
(e.g. - 2019-10-02 10:19:23-0800
representation of the time. however, I cannot figure out how to do so since from what I've saw OffsetDateTime
expect a different format for the Timezone.
Another option might be to do it on the database level - but I couldn't figure out a way to do this as well...
EDIT:
If you have both the local time and the timezone you can use ZonedDateTime
as follow:
final date = new LocalDateTime(...);
final String timezone = ...;
ZonedDateTime.of(date, ZoneOffset.of(zone));