I want to get the difference in seconds to find whether the system timezone is ahead or behind the remote timezone. Here the remote timezone value is "GMT" which i fetch from Database. It could be "US/Eastern", which i convert to "America/New_York". But for GMT, im getting ERROR.
ZoneId.systemDefault().getRules().getOffset(Instant.now()).getTotalSeconds()
- ZoneId.of("GMT").getRules().getOffset(Instant.now()).getTotalSeconds()
But it gives the following error,
Exception in thread "main" java.time.DateTimeException: Invalid ID for ZoneOffset, invalid format:
at java.time.ZoneOffset.of(Unknown Source)
at java.time.ZoneId.of(Unknown Source)
at java.time.ZoneId.of(Unknown Source)
How to resolve this error ? What to use in place of GMT ??
ZoneId.of(String)
. No need to convert. The problem here is elsewhere. – Landsman7200
. – Collect