661 }
662 }
663
664 // Get the time zone for zoneID. But not fall back to
665 // "GMT" here.
666 tz = getTimeZone(zoneID, false);
667
668 if (tz == null) {
669 // If the given zone ID is unknown in Java, try to
670 // get the GMT-offset-based time zone ID,
671 // a.k.a. custom time zone ID (e.g., "GMT-08:00").
672 String gmtOffsetID = getSystemGMTOffsetID();
673 if (gmtOffsetID != null) {
674 zoneID = gmtOffsetID;
675 }
676 tz = getTimeZone(zoneID, true);
677 }
678 assert tz != null;
679
680 final String id = zoneID;
681 AccessController.doPrivileged(new PrivilegedAction<Void>() {
682 @Override
683 public Void run() {
684 System.setProperty("user.timezone", id);
685 return null;
686 }
687 });
688
689 defaultTimeZone = tz;
690 return tz;
691 }
692
693 /**
694 * Sets the {@code TimeZone} that is returned by the {@code getDefault}
695 * method. {@code zone} is cached. If {@code zone} is null, the cached
696 * default {@code TimeZone} is cleared. This method doesn't change the value
697 * of the {@code user.timezone} property.
698 *
699 * @param zone the new default {@code TimeZone}, or null
700 * @throws SecurityException if the security manager's {@code checkPermission}
701 * denies {@code PropertyPermission("user.timezone",
|
661 }
662 }
663
664 // Get the time zone for zoneID. But not fall back to
665 // "GMT" here.
666 tz = getTimeZone(zoneID, false);
667
668 if (tz == null) {
669 // If the given zone ID is unknown in Java, try to
670 // get the GMT-offset-based time zone ID,
671 // a.k.a. custom time zone ID (e.g., "GMT-08:00").
672 String gmtOffsetID = getSystemGMTOffsetID();
673 if (gmtOffsetID != null) {
674 zoneID = gmtOffsetID;
675 }
676 tz = getTimeZone(zoneID, true);
677 }
678 assert tz != null;
679
680 final String id = zoneID;
681 AccessController.doPrivileged(new PrivilegedAction<>() {
682 @Override
683 public Void run() {
684 System.setProperty("user.timezone", id);
685 return null;
686 }
687 });
688
689 defaultTimeZone = tz;
690 return tz;
691 }
692
693 /**
694 * Sets the {@code TimeZone} that is returned by the {@code getDefault}
695 * method. {@code zone} is cached. If {@code zone} is null, the cached
696 * default {@code TimeZone} is cleared. This method doesn't change the value
697 * of the {@code user.timezone} property.
698 *
699 * @param zone the new default {@code TimeZone}, or null
700 * @throws SecurityException if the security manager's {@code checkPermission}
701 * denies {@code PropertyPermission("user.timezone",
|