fork(1) download
  1. import java.time.ZoneId;
  2. import java.time.zone.ZoneRulesException;
  3. import java.util.stream.Stream;
  4.  
  5. public class Main {
  6. public static void main(String[] args) {
  7. Stream.of(
  8. "America/New_York",
  9. "GMT",
  10. "UTC",
  11. "UCT",
  12. "GMT+01:00",
  13. "UTC+01:00",
  14. "ABC"
  15. ).forEach(s -> {
  16. try {
  17. System.out.println(ZoneId.of(s));
  18. } catch (ZoneRulesException e) {
  19. System.out.println(e.getMessage());
  20. }
  21. });
  22. }
  23. }
Success #stdin #stdout 0.1s 51628KB
stdin
Standard input is empty
stdout
America/New_York
GMT
UTC
UCT
GMT+01:00
UTC+01:00
Unknown time-zone ID: ABC