711 setDefaultInAppContext(null); 712 } 713 } else { 714 setDefaultInAppContext(zone); 715 } 716 } 717 718 /** 719 * Returns the default TimeZone in an AppContext if any AppContext 720 * has ever used. null is returned if any AppContext hasn't been 721 * used or if the AppContext doesn't have the default TimeZone. 722 * 723 * Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't 724 * been loaded. If so, it implies that AWTSecurityManager is not our 725 * SecurityManager and we can use a local static variable. 726 * This works around a build time issue. 727 */ 728 private static TimeZone getDefaultInAppContext() { 729 // JavaAWTAccess provides access implementation-private methods without using reflection. 730 JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess(); 731 if (javaAWTAccess == null) { 732 return mainAppContextDefault; 733 } else { 734 if (!javaAWTAccess.isDisposed()) { 735 TimeZone tz = (TimeZone) 736 javaAWTAccess.get(TimeZone.class); 737 if (tz == null && javaAWTAccess.isMainAppContext()) { 738 return mainAppContextDefault; 739 } else { 740 return tz; 741 } 742 } 743 } 744 return null; 745 } 746 747 /** 748 * Sets the default TimeZone in the AppContext to the given 749 * tz. null is handled special: do nothing if any AppContext 750 * hasn't been used, remove the default TimeZone in the 751 * AppContext otherwise. 752 * 753 * Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't 754 * been loaded. If so, it implies that AWTSecurityManager is not our 755 * SecurityManager and we can use a local static variable. 756 * This works around a build time issue. 757 */ 758 private static void setDefaultInAppContext(TimeZone tz) { 759 // JavaAWTAccess provides access implementation-private methods without using reflection. 760 JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess(); 761 if (javaAWTAccess == null) { 762 mainAppContextDefault = tz; 763 } else { 764 if (!javaAWTAccess.isDisposed()) { 765 javaAWTAccess.put(TimeZone.class, tz); 766 if (javaAWTAccess.isMainAppContext()) { 767 mainAppContextDefault = null; 768 } 769 } 770 } 771 } 772 773 /** 774 * Returns true if this zone has the same rule and offset as another zone. 775 * That is, if this zone differs only in ID, if at all. Returns false 776 * if the other zone is null. 777 * @param other the <code>TimeZone</code> object to be compared with 778 * @return true if the other zone is not null and is the same as this one, 779 * with the possible exception of the ID 780 * @since 1.2 781 */ 782 public boolean hasSameRules(TimeZone other) { 783 return other != null && getRawOffset() == other.getRawOffset() && 784 useDaylightTime() == other.useDaylightTime(); 785 } 786 787 /** 788 * Creates a copy of this <code>TimeZone</code>. 789 * 790 * @return a clone of this <code>TimeZone</code> | 711 setDefaultInAppContext(null); 712 } 713 } else { 714 setDefaultInAppContext(zone); 715 } 716 } 717 718 /** 719 * Returns the default TimeZone in an AppContext if any AppContext 720 * has ever used. null is returned if any AppContext hasn't been 721 * used or if the AppContext doesn't have the default TimeZone. 722 * 723 * Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't 724 * been loaded. If so, it implies that AWTSecurityManager is not our 725 * SecurityManager and we can use a local static variable. 726 * This works around a build time issue. 727 */ 728 private static TimeZone getDefaultInAppContext() { 729 // JavaAWTAccess provides access implementation-private methods without using reflection. 730 JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess(); 731 if (System.getSecurityManager() == null || javaAWTAccess == null) { 732 return mainAppContextDefault; 733 } else if (javaAWTAccess != null) { 734 if (javaAWTAccess.isDisposed()) { 735 return null; 736 } else { 737 TimeZone tz = (TimeZone) javaAWTAccess.get(TimeZone.class); 738 if (tz == null && javaAWTAccess.isMainAppContext()) { 739 return mainAppContextDefault; 740 } else { 741 return tz; 742 } 743 } 744 } 745 return null; 746 } 747 748 /** 749 * Sets the default TimeZone in the AppContext to the given 750 * tz. null is handled special: do nothing if any AppContext 751 * hasn't been used, remove the default TimeZone in the 752 * AppContext otherwise. 753 * 754 * Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't 755 * been loaded. If so, it implies that AWTSecurityManager is not our 756 * SecurityManager and we can use a local static variable. 757 * This works around a build time issue. 758 */ 759 private static void setDefaultInAppContext(TimeZone tz) { 760 // JavaAWTAccess provides access implementation-private methods without using reflection. 761 JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess(); 762 if (System.getSecurityManager() == null || javaAWTAccess == null) { 763 mainAppContextDefault = tz; 764 } else if (javaAWTAccess != null && !javaAWTAccess.isDisposed()) { 765 javaAWTAccess.put(TimeZone.class, tz); 766 if (javaAWTAccess.isMainAppContext()) { 767 mainAppContextDefault = null; 768 } 769 } 770 } 771 772 /** 773 * Returns true if this zone has the same rule and offset as another zone. 774 * That is, if this zone differs only in ID, if at all. Returns false 775 * if the other zone is null. 776 * @param other the <code>TimeZone</code> object to be compared with 777 * @return true if the other zone is not null and is the same as this one, 778 * with the possible exception of the ID 779 * @since 1.2 780 */ 781 public boolean hasSameRules(TimeZone other) { 782 return other != null && getRawOffset() == other.getRawOffset() && 783 useDaylightTime() == other.useDaylightTime(); 784 } 785 786 /** 787 * Creates a copy of this <code>TimeZone</code>. 788 * 789 * @return a clone of this <code>TimeZone</code> |