equal
deleted
inserted
replaced
40 |
40 |
41 import java.io.Serializable; |
41 import java.io.Serializable; |
42 import java.security.AccessController; |
42 import java.security.AccessController; |
43 import java.security.PrivilegedAction; |
43 import java.security.PrivilegedAction; |
44 import java.time.ZoneId; |
44 import java.time.ZoneId; |
|
45 import java.util.Properties; |
45 import sun.security.action.GetPropertyAction; |
46 import sun.security.action.GetPropertyAction; |
46 import sun.util.calendar.ZoneInfo; |
47 import sun.util.calendar.ZoneInfo; |
47 import sun.util.calendar.ZoneInfoFile; |
48 import sun.util.calendar.ZoneInfoFile; |
48 import sun.util.locale.provider.TimeZoneNameUtility; |
49 import sun.util.locale.provider.TimeZoneNameUtility; |
49 |
50 |
658 } |
659 } |
659 |
660 |
660 private static synchronized TimeZone setDefaultZone() { |
661 private static synchronized TimeZone setDefaultZone() { |
661 TimeZone tz; |
662 TimeZone tz; |
662 // get the time zone ID from the system properties |
663 // get the time zone ID from the system properties |
663 String zoneID = GetPropertyAction.getProperty("user.timezone"); |
664 Properties props = GetPropertyAction.privilegedGetProperties(); |
|
665 String zoneID = props.getProperty("user.timezone"); |
664 |
666 |
665 // if the time zone ID is not set (yet), perform the |
667 // if the time zone ID is not set (yet), perform the |
666 // platform to Java time zone ID mapping. |
668 // platform to Java time zone ID mapping. |
667 if (zoneID == null || zoneID.isEmpty()) { |
669 if (zoneID == null || zoneID.isEmpty()) { |
668 String javaHome = GetPropertyAction.getProperty("java.home"); |
670 String javaHome = props.getProperty("java.home"); |
669 try { |
671 try { |
670 zoneID = getSystemTimeZoneID(javaHome); |
672 zoneID = getSystemTimeZoneID(javaHome); |
671 if (zoneID == null) { |
673 if (zoneID == null) { |
672 zoneID = GMT_ID; |
674 zoneID = GMT_ID; |
673 } |
675 } |
691 tz = getTimeZone(zoneID, true); |
693 tz = getTimeZone(zoneID, true); |
692 } |
694 } |
693 assert tz != null; |
695 assert tz != null; |
694 |
696 |
695 final String id = zoneID; |
697 final String id = zoneID; |
696 AccessController.doPrivileged(new PrivilegedAction<>() { |
698 props.setProperty("user.timezone", id); |
697 @Override |
|
698 public Void run() { |
|
699 System.setProperty("user.timezone", id); |
|
700 return null; |
|
701 } |
|
702 }); |
|
703 |
699 |
704 defaultTimeZone = tz; |
700 defaultTimeZone = tz; |
705 return tz; |
701 return tz; |
706 } |
702 } |
707 |
703 |