I have a LocalDateTime
field representing a date and time, and a separate timezone
string which tells its time zone.
I want to convert the time in the LocalDateTime
to eastern timezone.
I found several answers explaining this, but all of them use the IANA's naming standard of zone ids of Continent/Region for conversion. I am getting the short form notation of zone ids in the timezone
field from the user which is like IST, AEST, CST, etc.
Is there a way I can convert time to eastern time format using the short notations?
UPDATE: I have a limited set of time zones which can be given as input. They are as follows:
JST
- Japan Standard Time (+09:00)CST
- China Standard Time (+08:00)SAST
- South African Standard Time (+02:00)CET
- Central European Time (+01:00 / +02:00)GMT
- Greenwich Mean Time (00:00)ET
- Eastern Time Zone (-05:00 / -04:00)BST
- British Summer Time (+01:00 / 00:00)HKT
- Hong Kong Time (+08:00)IST
- Indian Standard Time (+05:30)GST
- Gulf Standard Time (+04:00)MSK
- Moscow Standard Time (+03:00)BRT
- Brasília Time (-03:00)NZST
- New Zealand Standard Time (+12:00 / +13:00)AEST
- Australian Eastern Standard Time (+10:00 / +11:00)
The conversion strategy should take care of DST. So if input is 2021-01-06T10:30:00
and time zone given is IST
. The method while converting this to EST should figure out if DST applies or not and do the conversion accordingly with either -05:00
or -04:00
as applicable.