| 11 | } |
| 12 | |
| 13 | public static ZoneId of(String zoneId) { |
| 14 | if (zoneId == null) { |
| 15 | throw new NullPointerException(); |
| 16 | } |
| 17 | if ("Z".equals(zoneId) || "UTC".equals(zoneId) || "GMT".equals(zoneId)) { |
| 18 | return ZoneOffset.UTC; |
| 19 | } |
| 20 | if (zoneId.startsWith("+") || zoneId.startsWith("-")) { |
| 21 | return ZoneOffset.of(zoneId); |
| 22 | } |
| 23 | if (zoneId.startsWith("UTC+") || zoneId.startsWith("UTC-")) { |
| 24 | return ZoneOffset.of(zoneId.substring(3)); |
| 25 | } |
| 26 | if (zoneId.startsWith("GMT+") || zoneId.startsWith("GMT-")) { |
| 27 | return ZoneOffset.of(zoneId.substring(3)); |
| 28 | } |
| 29 | return new ZoneId(zoneId); |
| 30 | } |
| 31 | |
| 32 | public static ZoneId systemDefault() { |
| 33 | return of(TimeZone.getDefault().getID()); |