There's actually significantly more offsets than what you had originally thought - from that Wikipedia article, there are about 40 of them.
The reason for this is multiple:
- Different countries may choose to offset their clocks to either be hours and hours behind Grenwich, or hours and hours ahead of Grenwich.
- Different countries permit offsets which aren't by the hour; Newfoundland in parts for instance has an offset of a half-hour. Nepal has an offset of 45 minutes.
- Governments may arbitrarily decide to change their timezones at will, which means that the number of offsets that exist is always in flux. Case in point: Samoa jumped across the International Date Line.
Armed with this knowledge, you should take some solace in knowing that Java's ZoneOffset
supports an offset range of +18:00 to -18:00, and ZoneOffset.of
accepts a String
parameter. If you really wanted to enumerate all of the known possible timezones, you could use some string manipulation and generate the possible timezones that way (and keep track of the ones that are valid, or don't throw a DateTimeException
), but I leave this as an exercise for the reader.