1.1 --- a/rt/emul/compact/src/main/java/java/util/Calendar.java Fri Oct 04 11:07:00 2013 +0200
1.2 +++ b/rt/emul/compact/src/main/java/java/util/Calendar.java Fri Oct 04 12:01:56 2013 +0200
1.3 @@ -43,19 +43,13 @@
1.4 import java.io.ObjectOutputStream;
1.5 import java.io.OptionalDataException;
1.6 import java.io.Serializable;
1.7 -import java.security.AccessControlContext;
1.8 import java.security.AccessController;
1.9 -import java.security.PermissionCollection;
1.10 import java.security.PrivilegedActionException;
1.11 import java.security.PrivilegedExceptionAction;
1.12 -import java.security.ProtectionDomain;
1.13 import java.text.DateFormat;
1.14 import java.text.DateFormatSymbols;
1.15 import java.util.concurrent.ConcurrentHashMap;
1.16 import java.util.concurrent.ConcurrentMap;
1.17 -import sun.util.BuddhistCalendar;
1.18 -import sun.util.calendar.ZoneInfo;
1.19 -import sun.util.resources.LocaleData;
1.20
1.21 /**
1.22 * The <code>Calendar</code> class is an abstract class that provides methods
1.23 @@ -1025,18 +1019,18 @@
1.24 // returns a BuddhistCalendar instance.
1.25 if ("th".equals(aLocale.getLanguage())
1.26 && ("TH".equals(aLocale.getCountry()))) {
1.27 - cal = new BuddhistCalendar(zone, aLocale);
1.28 +// cal = new BuddhistCalendar(zone, aLocale);
1.29 } else {
1.30 - cal = new GregorianCalendar(zone, aLocale);
1.31 +// cal = new GregorianCalendar(zone, aLocale);
1.32 }
1.33 } else if (caltype.equals("japanese")) {
1.34 - cal = new JapaneseImperialCalendar(zone, aLocale);
1.35 +// cal = new JapaneseImperialCalendar(zone, aLocale);
1.36 } else if (caltype.equals("buddhist")) {
1.37 - cal = new BuddhistCalendar(zone, aLocale);
1.38 +// cal = new BuddhistCalendar(zone, aLocale);
1.39 } else {
1.40 // Unsupported calendar type.
1.41 // Use Gregorian calendar as a fallback.
1.42 - cal = new GregorianCalendar(zone, aLocale);
1.43 +// cal = new GregorianCalendar(zone, aLocale);
1.44 }
1.45
1.46 return cal;
1.47 @@ -1130,10 +1124,10 @@
1.48 public void setTimeInMillis(long millis) {
1.49 // If we don't need to recalculate the calendar field values,
1.50 // do nothing.
1.51 - if (time == millis && isTimeSet && areFieldsSet && areAllFieldsSet
1.52 - && (zone instanceof ZoneInfo) && !((ZoneInfo)zone).isDirty()) {
1.53 - return;
1.54 - }
1.55 +// if (time == millis && isTimeSet && areFieldsSet && areAllFieldsSet
1.56 +// && (zone instanceof ZoneInfo) && !((ZoneInfo)zone).isDirty()) {
1.57 +// return;
1.58 +// }
1.59 time = millis;
1.60 isTimeSet = true;
1.61 areFieldsSet = false;
1.62 @@ -2587,10 +2581,10 @@
1.63 /* try to get the Locale data from the cache */
1.64 int[] data = cachedLocaleData.get(desiredLocale);
1.65 if (data == null) { /* cache miss */
1.66 - ResourceBundle bundle = LocaleData.getCalendarData(desiredLocale);
1.67 +// ResourceBundle bundle = LocaleData.getCalendarData(desiredLocale);
1.68 data = new int[2];
1.69 - data[0] = Integer.parseInt(bundle.getString("firstDayOfWeek"));
1.70 - data[1] = Integer.parseInt(bundle.getString("minimalDaysInFirstWeek"));
1.71 +// data[0] = Integer.parseInt(bundle.getString("firstDayOfWeek"));
1.72 +// data[1] = Integer.parseInt(bundle.getString("minimalDaysInFirstWeek"));
1.73 cachedLocaleData.putIfAbsent(desiredLocale, data);
1.74 }
1.75 firstDayOfWeek = data[0];
1.76 @@ -2721,14 +2715,14 @@
1.77 // SimpleTimeZone equivalent (as a single DST schedule) for
1.78 // backward compatibility.
1.79 TimeZone savedZone = null;
1.80 - if (zone instanceof ZoneInfo) {
1.81 - SimpleTimeZone stz = ((ZoneInfo)zone).getLastRuleInstance();
1.82 - if (stz == null) {
1.83 - stz = new SimpleTimeZone(zone.getRawOffset(), zone.getID());
1.84 - }
1.85 - savedZone = zone;
1.86 - zone = stz;
1.87 - }
1.88 +// if (zone instanceof ZoneInfo) {
1.89 +// SimpleTimeZone stz = ((ZoneInfo)zone).getLastRuleInstance();
1.90 +// if (stz == null) {
1.91 +// stz = new SimpleTimeZone(zone.getRawOffset(), zone.getID());
1.92 +// }
1.93 +// savedZone = zone;
1.94 +// zone = stz;
1.95 +// }
1.96
1.97 // Write out the 1.1 FCS object.
1.98 stream.defaultWriteObject();
1.99 @@ -2742,18 +2736,6 @@
1.100 }
1.101 }
1.102
1.103 - private static class CalendarAccessControlContext {
1.104 - private static final AccessControlContext INSTANCE;
1.105 - static {
1.106 - RuntimePermission perm = new RuntimePermission("accessClassInPackage.sun.util.calendar");
1.107 - PermissionCollection perms = perm.newPermissionCollection();
1.108 - perms.add(perm);
1.109 - INSTANCE = new AccessControlContext(new ProtectionDomain[] {
1.110 - new ProtectionDomain(null, perms)
1.111 - });
1.112 - }
1.113 - }
1.114 -
1.115 /**
1.116 * Reconstitutes this object from a stream (i.e., deserialize it).
1.117 */
1.118 @@ -2783,28 +2765,28 @@
1.119 serialVersionOnStream = currentSerialVersion;
1.120
1.121 // If there's a ZoneInfo object, use it for zone.
1.122 - ZoneInfo zi = null;
1.123 - try {
1.124 - zi = AccessController.doPrivileged(
1.125 - new PrivilegedExceptionAction<ZoneInfo>() {
1.126 - public ZoneInfo run() throws Exception {
1.127 - return (ZoneInfo) input.readObject();
1.128 - }
1.129 - },
1.130 - CalendarAccessControlContext.INSTANCE);
1.131 - } catch (PrivilegedActionException pae) {
1.132 - Exception e = pae.getException();
1.133 - if (!(e instanceof OptionalDataException)) {
1.134 - if (e instanceof RuntimeException) {
1.135 - throw (RuntimeException) e;
1.136 - } else if (e instanceof IOException) {
1.137 - throw (IOException) e;
1.138 - } else if (e instanceof ClassNotFoundException) {
1.139 - throw (ClassNotFoundException) e;
1.140 - }
1.141 - throw new RuntimeException(e);
1.142 - }
1.143 - }
1.144 + TimeZone zi = null;
1.145 +// try {
1.146 +// zi = AccessController.doPrivileged(
1.147 +// new PrivilegedExceptionAction<ZoneInfo>() {
1.148 +// public ZoneInfo run() throws Exception {
1.149 +// return (ZoneInfo) input.readObject();
1.150 +// }
1.151 +// },
1.152 +// CalendarAccessControlContext.INSTANCE);
1.153 +// } catch (PrivilegedActionException pae) {
1.154 +// Exception e = pae.getException();
1.155 +// if (!(e instanceof OptionalDataException)) {
1.156 +// if (e instanceof RuntimeException) {
1.157 +// throw (RuntimeException) e;
1.158 +// } else if (e instanceof IOException) {
1.159 +// throw (IOException) e;
1.160 +// } else if (e instanceof ClassNotFoundException) {
1.161 +// throw (ClassNotFoundException) e;
1.162 +// }
1.163 +// throw new RuntimeException(e);
1.164 +// }
1.165 +// }
1.166 if (zi != null) {
1.167 zone = zi;
1.168 }
2.1 --- a/rt/emul/compact/src/main/java/java/util/Currency.java Fri Oct 04 11:07:00 2013 +0200
2.2 +++ b/rt/emul/compact/src/main/java/java/util/Currency.java Fri Oct 04 12:01:56 2013 +0200
2.3 @@ -35,14 +35,7 @@
2.4 import java.security.AccessController;
2.5 import java.security.PrivilegedAction;
2.6 import java.util.logging.Level;
2.7 -import java.util.regex.Pattern;
2.8 -import java.util.regex.Matcher;
2.9 -import java.util.spi.CurrencyNameProvider;
2.10 -import java.util.spi.LocaleServiceProvider;
2.11 -import sun.util.LocaleServiceProviderPool;
2.12 -import sun.util.logging.PlatformLogger;
2.13 -import sun.util.resources.LocaleData;
2.14 -import sun.util.resources.OpenListResourceBundle;
2.15 +import java.util.logging.Logger;
2.16
2.17
2.18 /**
2.19 @@ -227,27 +220,27 @@
2.20 }
2.21
2.22 // look for the properties file for overrides
2.23 - try {
2.24 +// try {
2.25 File propFile = new File(homeDir + File.separator +
2.26 "lib" + File.separator +
2.27 "currency.properties");
2.28 - if (propFile.exists()) {
2.29 - Properties props = new Properties();
2.30 - try (FileReader fr = new FileReader(propFile)) {
2.31 - props.load(fr);
2.32 - }
2.33 - Set<String> keys = props.stringPropertyNames();
2.34 - Pattern propertiesPattern =
2.35 - Pattern.compile("([A-Z]{3})\\s*,\\s*(\\d{3})\\s*,\\s*([0-3])");
2.36 - for (String key : keys) {
2.37 - replaceCurrencyData(propertiesPattern,
2.38 - key.toUpperCase(Locale.ROOT),
2.39 - props.getProperty(key).toUpperCase(Locale.ROOT));
2.40 - }
2.41 - }
2.42 - } catch (IOException e) {
2.43 - info("currency.properties is ignored because of an IOException", e);
2.44 - }
2.45 +// if (propFile.exists()) {
2.46 +// Properties props = new Properties();
2.47 +// try (FileReader fr = new FileReader(propFile)) {
2.48 +// props.load(fr);
2.49 +// }
2.50 +// Set<String> keys = props.stringPropertyNames();
2.51 +// Pattern propertiesPattern =
2.52 +// Pattern.compile("([A-Z]{3})\\s*,\\s*(\\d{3})\\s*,\\s*([0-3])");
2.53 +// for (String key : keys) {
2.54 +// replaceCurrencyData(propertiesPattern,
2.55 +// key.toUpperCase(Locale.ROOT),
2.56 +// props.getProperty(key).toUpperCase(Locale.ROOT));
2.57 +// }
2.58 +// }
2.59 +// } catch (IOException e) {
2.60 +// info("currency.properties is ignored because of an IOException", e);
2.61 +// }
2.62 return null;
2.63 }
2.64 });
2.65 @@ -472,6 +465,7 @@
2.66 try {
2.67 // Check whether a provider can provide an implementation that's closer
2.68 // to the requested locale than what the Java runtime itself can provide.
2.69 + /*
2.70 LocaleServiceProviderPool pool =
2.71 LocaleServiceProviderPool.getPool(CurrencyNameProvider.class);
2.72
2.73 @@ -489,8 +483,8 @@
2.74 return symbol;
2.75 }
2.76 }
2.77 -
2.78 - ResourceBundle bundle = LocaleData.getCurrencyNames(locale);
2.79 + */
2.80 + ResourceBundle bundle = null; //LocaleData.getCurrencyNames(locale);
2.81 return bundle.getString(currencyCode);
2.82 } catch (MissingResourceException e) {
2.83 // use currency code as symbol of last resort
2.84 @@ -545,31 +539,31 @@
2.85 * @since 1.7
2.86 */
2.87 public String getDisplayName(Locale locale) {
2.88 - try {
2.89 - OpenListResourceBundle bundle = LocaleData.getCurrencyNames(locale);
2.90 - String result = null;
2.91 - String bundleKey = currencyCode.toLowerCase(Locale.ROOT);
2.92 -
2.93 - // Check whether a provider can provide an implementation that's closer
2.94 - // to the requested locale than what the Java runtime itself can provide.
2.95 - LocaleServiceProviderPool pool =
2.96 - LocaleServiceProviderPool.getPool(CurrencyNameProvider.class);
2.97 - if (pool.hasProviders()) {
2.98 - result = pool.getLocalizedObject(
2.99 - CurrencyNameGetter.INSTANCE,
2.100 - locale, bundleKey, bundle, currencyCode, DISPLAYNAME);
2.101 - }
2.102 -
2.103 - if (result == null) {
2.104 - result = bundle.getString(bundleKey);
2.105 - }
2.106 -
2.107 - if (result != null) {
2.108 - return result;
2.109 - }
2.110 - } catch (MissingResourceException e) {
2.111 - // fall through
2.112 - }
2.113 +// try {
2.114 +// OpenListResourceBundle bundle = LocaleData.getCurrencyNames(locale);
2.115 +// String result = null;
2.116 +// String bundleKey = currencyCode.toLowerCase(Locale.ROOT);
2.117 +//
2.118 +// // Check whether a provider can provide an implementation that's closer
2.119 +// // to the requested locale than what the Java runtime itself can provide.
2.120 +// LocaleServiceProviderPool pool =
2.121 +// LocaleServiceProviderPool.getPool(CurrencyNameProvider.class);
2.122 +// if (pool.hasProviders()) {
2.123 +// result = pool.getLocalizedObject(
2.124 +// CurrencyNameGetter.INSTANCE,
2.125 +// locale, bundleKey, bundle, currencyCode, DISPLAYNAME);
2.126 +// }
2.127 +//
2.128 +// if (result == null) {
2.129 +// result = bundle.getString(bundleKey);
2.130 +// }
2.131 +//
2.132 +// if (result != null) {
2.133 +// return result;
2.134 +// }
2.135 +// } catch (MissingResourceException e) {
2.136 +// // fall through
2.137 +// }
2.138
2.139 // use currency code as symbol of last resort
2.140 return currencyCode;
2.141 @@ -616,7 +610,6 @@
2.142 /**
2.143 * Obtains a localized currency names from a CurrencyNameProvider
2.144 * implementation.
2.145 - */
2.146 private static class CurrencyNameGetter
2.147 implements LocaleServiceProviderPool.LocalizedObjectGetter<CurrencyNameProvider,
2.148 String> {
2.149 @@ -641,6 +634,7 @@
2.150 return null;
2.151 }
2.152 }
2.153 + */
2.154
2.155 private static int[] readIntArray(DataInputStream dis, int count) throws IOException {
2.156 int[] ret = new int[count];
2.157 @@ -679,7 +673,6 @@
2.158 * and "one-digit (0,1,2, or 3) default fraction digit".
2.159 * For example, "JPZ,392,0".
2.160 * @throws
2.161 - */
2.162 private static void replaceCurrencyData(Pattern pattern, String ctry, String curdata) {
2.163
2.164 if (ctry.length() != 2) {
2.165 @@ -727,12 +720,13 @@
2.166 }
2.167 setMainTableEntry(ctry.charAt(0), ctry.charAt(1), entry);
2.168 }
2.169 + */
2.170
2.171 private static void info(String message, Throwable t) {
2.172 - PlatformLogger logger = PlatformLogger.getLogger("java.util.Currency");
2.173 - if (logger.isLoggable(PlatformLogger.INFO)) {
2.174 + Logger logger = Logger.getLogger("java.util.Currency");
2.175 + if (logger.isLoggable(Level.INFO)) {
2.176 if (t != null) {
2.177 - logger.info(message, t);
2.178 + logger.log(Level.INFO, message, t);
2.179 } else {
2.180 logger.info(message);
2.181 }
3.1 --- a/rt/emul/compact/src/main/java/java/util/Date.java Fri Oct 04 11:07:00 2013 +0200
3.2 +++ b/rt/emul/compact/src/main/java/java/util/Date.java Fri Oct 04 12:01:56 2013 +0200
3.3 @@ -29,14 +29,6 @@
3.4 import java.io.IOException;
3.5 import java.io.ObjectOutputStream;
3.6 import java.io.ObjectInputStream;
3.7 -import java.lang.ref.SoftReference;
3.8 -import sun.util.calendar.BaseCalendar;
3.9 -import sun.util.calendar.CalendarDate;
3.10 -import sun.util.calendar.CalendarSystem;
3.11 -import sun.util.calendar.CalendarUtils;
3.12 -import sun.util.calendar.Era;
3.13 -import sun.util.calendar.Gregorian;
3.14 -import sun.util.calendar.ZoneInfo;
3.15
3.16 /**
3.17 * The class <code>Date</code> represents a specific instant
3.18 @@ -129,8 +121,8 @@
3.19 public class Date
3.20 implements java.io.Serializable, Cloneable, Comparable<Date>
3.21 {
3.22 - private static final BaseCalendar gcal =
3.23 - CalendarSystem.getGregorianCalendar();
3.24 + private static final BaseCalendar gcal = new BaseCalendar();
3.25 +
3.26 private static BaseCalendar jcal;
3.27
3.28 private transient long fastTime;
3.29 @@ -141,7 +133,7 @@
3.30 * synch. Otherwise, fastTime is ignored, and cdate indicates the
3.31 * time.
3.32 */
3.33 - private transient BaseCalendar.Date cdate;
3.34 + private transient BaseCalendar.Datum cdate;
3.35
3.36 // Initialized just before the value is used. See parse().
3.37 private static int defaultCenturyStart;
3.38 @@ -245,11 +237,11 @@
3.39 y += month / 12;
3.40 month %= 12;
3.41 } else if (month < 0) {
3.42 - y += CalendarUtils.floorDivide(month, 12);
3.43 - month = CalendarUtils.mod(month, 12);
3.44 + y += month / 12;
3.45 + month = month % 12;
3.46 }
3.47 BaseCalendar cal = getCalendarSystem(y);
3.48 - cdate = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.getDefaultRef());
3.49 + cdate = (BaseCalendar.Datum) cal.newCalendarDate(TimeZone.getDefaultRef());
3.50 cdate.setNormalizedDate(y, month + 1, date).setTimeOfDay(hrs, min, sec, 0);
3.51 getTimeImpl();
3.52 cdate = null;
3.53 @@ -280,7 +272,7 @@
3.54 try {
3.55 d = (Date)super.clone();
3.56 if (cdate != null) {
3.57 - d.cdate = (BaseCalendar.Date) cdate.clone();
3.58 + d.cdate = (BaseCalendar.Datum) cdate.clone();
3.59 }
3.60 } catch (CloneNotSupportedException e) {} // Won't happen
3.61 return d;
3.62 @@ -320,12 +312,12 @@
3.63 y += month / 12;
3.64 month %= 12;
3.65 } else if (month < 0) {
3.66 - y += CalendarUtils.floorDivide(month, 12);
3.67 - month = CalendarUtils.mod(month, 12);
3.68 + y += month / 12;
3.69 + month = month % 12;
3.70 }
3.71 int m = month + 1;
3.72 BaseCalendar cal = getCalendarSystem(y);
3.73 - BaseCalendar.Date udate = (BaseCalendar.Date) cal.newCalendarDate(null);
3.74 + BaseCalendar.Datum udate = (BaseCalendar.Datum) cal.newCalendarDate(null);
3.75 udate.setNormalizedDate(y, m, date).setTimeOfDay(hrs, min, sec, 0);
3.76
3.77 // Use a Date instance to perform normalization. Its fastTime
3.78 @@ -601,12 +593,12 @@
3.79 hour = 0;
3.80 BaseCalendar cal = getCalendarSystem(year);
3.81 if (tzoffset == -1) { // no time zone specified, have to use local
3.82 - BaseCalendar.Date ldate = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.getDefaultRef());
3.83 + BaseCalendar.Datum ldate = (BaseCalendar.Datum) cal.newCalendarDate(TimeZone.getDefaultRef());
3.84 ldate.setDate(year, mon + 1, mday);
3.85 ldate.setTimeOfDay(hour, min, sec, 0);
3.86 return cal.getTime(ldate);
3.87 }
3.88 - BaseCalendar.Date udate = (BaseCalendar.Date) cal.newCalendarDate(null); // no time zone
3.89 + BaseCalendar.Datum udate = (BaseCalendar.Datum) cal.newCalendarDate(null); // no time zone
3.90 udate.setDate(year, mon + 1, mday);
3.91 udate.setTimeOfDay(hour, min, sec, 0);
3.92 return cal.getTime(udate) + tzoffset * (60 * 1000);
3.93 @@ -706,10 +698,10 @@
3.94 y = month / 12;
3.95 month %= 12;
3.96 } else if (month < 0) {
3.97 - y = CalendarUtils.floorDivide(month, 12);
3.98 - month = CalendarUtils.mod(month, 12);
3.99 + y = month / 12;
3.100 + month = month % 12;
3.101 }
3.102 - BaseCalendar.Date d = getCalendarDate();
3.103 + BaseCalendar.Datum d = getCalendarDate();
3.104 if (y != 0) {
3.105 d.setNormalizedYear(d.getNormalizedYear() + y);
3.106 }
3.107 @@ -770,7 +762,7 @@
3.108 */
3.109 @Deprecated
3.110 public int getDay() {
3.111 - return normalize().getDayOfWeek() - gcal.SUNDAY;
3.112 + return normalize().getDayOfWeek() - 7;//gcal.SUNDAY;
3.113 }
3.114
3.115 /**
3.116 @@ -956,7 +948,7 @@
3.117 if (date.cdate == null || date.cdate.isNormalized()) {
3.118 return date.fastTime;
3.119 }
3.120 - BaseCalendar.Date d = (BaseCalendar.Date) date.cdate.clone();
3.121 + BaseCalendar.Datum d = (BaseCalendar.Datum) date.cdate.clone();
3.122 return gcal.getTime(d);
3.123 }
3.124
3.125 @@ -1024,25 +1016,25 @@
3.126 */
3.127 public String toString() {
3.128 // "EEE MMM dd HH:mm:ss zzz yyyy";
3.129 - BaseCalendar.Date date = normalize();
3.130 + BaseCalendar.Datum date = normalize();
3.131 StringBuilder sb = new StringBuilder(28);
3.132 int index = date.getDayOfWeek();
3.133 - if (index == gcal.SUNDAY) {
3.134 + if (index == 7) {
3.135 index = 8;
3.136 }
3.137 convertToAbbr(sb, wtb[index]).append(' '); // EEE
3.138 convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' '); // MMM
3.139 - CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 2).append(' '); // dd
3.140 -
3.141 - CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':'); // HH
3.142 - CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':'); // mm
3.143 - CalendarUtils.sprintf0d(sb, date.getSeconds(), 2).append(' '); // ss
3.144 - TimeZone zi = date.getZone();
3.145 - if (zi != null) {
3.146 - sb.append(zi.getDisplayName(date.isDaylightTime(), zi.SHORT, Locale.US)); // zzz
3.147 - } else {
3.148 - sb.append("GMT");
3.149 - }
3.150 +// CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 2).append(' '); // dd
3.151 +//
3.152 +// CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':'); // HH
3.153 +// CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':'); // mm
3.154 +// CalendarUtils.sprintf0d(sb, date.getSeconds(), 2).append(' '); // ss
3.155 +// TimeZone zi = date.getZone();
3.156 +// if (zi != null) {
3.157 +// sb.append(zi.getDisplayName(date.isDaylightTime(), zi.SHORT, Locale.US)); // zzz
3.158 +// } else {
3.159 +// sb.append("GMT");
3.160 +// }
3.161 sb.append(' ').append(date.getYear()); // yyyy
3.162 return sb.toString();
3.163 }
3.164 @@ -1116,15 +1108,15 @@
3.165 // d MMM yyyy HH:mm:ss 'GMT'
3.166 long t = getTime();
3.167 BaseCalendar cal = getCalendarSystem(t);
3.168 - BaseCalendar.Date date =
3.169 - (BaseCalendar.Date) cal.getCalendarDate(getTime(), (TimeZone)null);
3.170 StringBuilder sb = new StringBuilder(32);
3.171 - CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 1).append(' '); // d
3.172 - convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' '); // MMM
3.173 - sb.append(date.getYear()).append(' '); // yyyy
3.174 - CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':'); // HH
3.175 - CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':'); // mm
3.176 - CalendarUtils.sprintf0d(sb, date.getSeconds(), 2); // ss
3.177 +// BaseCalendar.Datum date =
3.178 +// (BaseCalendar.Datum) cal.getCalendarDate(getTime(), (TimeZone)null);
3.179 +// CalendarUtils.sprintf0d(sb, date.getDayOfMonth(), 1).append(' '); // d
3.180 +// convertToAbbr(sb, wtb[date.getMonth() - 1 + 2 + 7]).append(' '); // MMM
3.181 +// sb.append(date.getYear()).append(' '); // yyyy
3.182 +// CalendarUtils.sprintf0d(sb, date.getHours(), 2).append(':'); // HH
3.183 +// CalendarUtils.sprintf0d(sb, date.getMinutes(), 2).append(':'); // mm
3.184 +// CalendarUtils.sprintf0d(sb, date.getSeconds(), 2); // ss
3.185 sb.append(" GMT"); // ' GMT'
3.186 return sb.toString();
3.187 }
3.188 @@ -1166,11 +1158,7 @@
3.189 int zoneOffset;
3.190 if (cdate == null) {
3.191 TimeZone tz = TimeZone.getDefaultRef();
3.192 - if (tz instanceof ZoneInfo) {
3.193 - zoneOffset = ((ZoneInfo)tz).getOffsets(fastTime, null);
3.194 - } else {
3.195 - zoneOffset = tz.getOffset(fastTime);
3.196 - }
3.197 + zoneOffset = tz.getOffset(fastTime);
3.198 } else {
3.199 normalize();
3.200 zoneOffset = cdate.getZoneOffset();
3.201 @@ -1178,21 +1166,21 @@
3.202 return -zoneOffset/60000; // convert to minutes
3.203 }
3.204
3.205 - private final BaseCalendar.Date getCalendarDate() {
3.206 + private final BaseCalendar.Datum getCalendarDate() {
3.207 if (cdate == null) {
3.208 - BaseCalendar cal = getCalendarSystem(fastTime);
3.209 - cdate = (BaseCalendar.Date) cal.getCalendarDate(fastTime,
3.210 - TimeZone.getDefaultRef());
3.211 +// BaseCalendar cal = getCalendarSystem(fastTime);
3.212 +// cdate = (BaseCalendar.Datum) cal.getCalendarDate(fastTime,
3.213 +// TimeZone.getDefaultRef());
3.214 }
3.215 return cdate;
3.216 }
3.217
3.218 - private final BaseCalendar.Date normalize() {
3.219 + private final BaseCalendar.Datum normalize() {
3.220 if (cdate == null) {
3.221 - BaseCalendar cal = getCalendarSystem(fastTime);
3.222 - cdate = (BaseCalendar.Date) cal.getCalendarDate(fastTime,
3.223 - TimeZone.getDefaultRef());
3.224 - return cdate;
3.225 +// BaseCalendar cal = getCalendarSystem(fastTime);
3.226 +// cdate = (BaseCalendar.Datum) cal.getCalendarDate(fastTime,
3.227 +// TimeZone.getDefaultRef());
3.228 +// return cdate;
3.229 }
3.230
3.231 // Normalize cdate with the TimeZone in cdate first. This is
3.232 @@ -1205,15 +1193,15 @@
3.233 // fields with the new TimeZone.
3.234 TimeZone tz = TimeZone.getDefaultRef();
3.235 if (tz != cdate.getZone()) {
3.236 - cdate.setZone(tz);
3.237 - CalendarSystem cal = getCalendarSystem(cdate);
3.238 - cal.getCalendarDate(fastTime, cdate);
3.239 +// cdate.setZone(tz);
3.240 +// CalendarSystem cal = getCalendarSystem(cdate);
3.241 +// cal.getCalendarDate(fastTime, cdate);
3.242 }
3.243 return cdate;
3.244 }
3.245
3.246 // fastTime and the returned data are in sync upon return.
3.247 - private final BaseCalendar.Date normalize(BaseCalendar.Date date) {
3.248 + private final BaseCalendar.Datum normalize(BaseCalendar.Datum date) {
3.249 int y = date.getNormalizedYear();
3.250 int m = date.getMonth();
3.251 int d = date.getDayOfMonth();
3.252 @@ -1231,23 +1219,23 @@
3.253 // ss and ms. Also, let GregorianCalendar handle the default
3.254 // cutover year so that we don't need to worry about the
3.255 // transition here.
3.256 - if (y == 1582 || y > 280000000 || y < -280000000) {
3.257 - if (tz == null) {
3.258 - tz = TimeZone.getTimeZone("GMT");
3.259 - }
3.260 - GregorianCalendar gc = new GregorianCalendar(tz);
3.261 - gc.clear();
3.262 - gc.set(gc.MILLISECOND, ms);
3.263 - gc.set(y, m-1, d, hh, mm, ss);
3.264 - fastTime = gc.getTimeInMillis();
3.265 - BaseCalendar cal = getCalendarSystem(fastTime);
3.266 - date = (BaseCalendar.Date) cal.getCalendarDate(fastTime, tz);
3.267 - return date;
3.268 - }
3.269 +// if (y == 1582 || y > 280000000 || y < -280000000) {
3.270 +// if (tz == null) {
3.271 +// tz = TimeZone.getTimeZone("GMT");
3.272 +// }
3.273 +// GregorianCalendar gc = new GregorianCalendar(tz);
3.274 +// gc.clear();
3.275 +// gc.set(gc.MILLISECOND, ms);
3.276 +// gc.set(y, m-1, d, hh, mm, ss);
3.277 +// fastTime = gc.getTimeInMillis();
3.278 +// BaseCalendar cal = getCalendarSystem(fastTime);
3.279 +// date = (BaseCalendar.Datum) cal.getCalendarDate(fastTime, tz);
3.280 +// return date;
3.281 +// }
3.282
3.283 BaseCalendar cal = getCalendarSystem(y);
3.284 if (cal != getCalendarSystem(date)) {
3.285 - date = (BaseCalendar.Date) cal.newCalendarDate(tz);
3.286 + date = (BaseCalendar.Datum) cal.newCalendarDate(tz);
3.287 date.setNormalizedDate(y, m, d).setTimeOfDay(hh, mm, ss, ms);
3.288 }
3.289 // Perform the GregorianCalendar-style normalization.
3.290 @@ -1257,7 +1245,7 @@
3.291 // system, we need to recalculate it using the other one.
3.292 BaseCalendar ncal = getCalendarSystem(fastTime);
3.293 if (ncal != cal) {
3.294 - date = (BaseCalendar.Date) ncal.newCalendarDate(tz);
3.295 + date = (BaseCalendar.Datum) ncal.newCalendarDate(tz);
3.296 date.setNormalizedDate(y, m, d).setTimeOfDay(hh, mm, ss, ms);
3.297 fastTime = ncal.getTime(date);
3.298 }
3.299 @@ -1282,15 +1270,15 @@
3.300 // Quickly check if the time stamp given by `utc' is the Epoch
3.301 // or later. If it's before 1970, we convert the cutover to
3.302 // local time to compare.
3.303 - if (utc >= 0
3.304 - || utc >= GregorianCalendar.DEFAULT_GREGORIAN_CUTOVER
3.305 - - TimeZone.getDefaultRef().getOffset(utc)) {
3.306 +// if (utc >= 0
3.307 +// || utc >= GregorianCalendar.DEFAULT_GREGORIAN_CUTOVER
3.308 +// - TimeZone.getDefaultRef().getOffset(utc)) {
3.309 return gcal;
3.310 - }
3.311 - return getJulianCalendar();
3.312 +// }
3.313 +// return getJulianCalendar();
3.314 }
3.315
3.316 - private static final BaseCalendar getCalendarSystem(BaseCalendar.Date cdate) {
3.317 + private static final BaseCalendar getCalendarSystem(BaseCalendar.Datum cdate) {
3.318 if (jcal == null) {
3.319 return gcal;
3.320 }
3.321 @@ -1302,7 +1290,7 @@
3.322
3.323 synchronized private static final BaseCalendar getJulianCalendar() {
3.324 if (jcal == null) {
3.325 - jcal = (BaseCalendar) CalendarSystem.forName("julian");
3.326 +// jcal = (BaseCalendar) CalendarSystem.forName("julian");
3.327 }
3.328 return jcal;
3.329 }
3.330 @@ -1328,4 +1316,115 @@
3.331 {
3.332 fastTime = s.readLong();
3.333 }
3.334 +
3.335 + static final class BaseCalendar {
3.336 + Datum newCalendarDate(TimeZone t) {
3.337 + return new Datum();
3.338 + }
3.339 +
3.340 + Datum getNthDayOfWeek(int a, int b, Datum c) {
3.341 + return new Datum();
3.342 + }
3.343 +
3.344 + Datum getCalendarDate() {
3.345 + return new Datum();
3.346 + }
3.347 +
3.348 + int getTime(Datum udate) {
3.349 + return 0;
3.350 + }
3.351 +
3.352 + int getMonthLength(Datum cdate) {
3.353 + return 0;
3.354 + }
3.355 +
3.356 + void getCalendarDate(long l, Datum cdate) {
3.357 + }
3.358 +
3.359 + static class Datum implements Cloneable {
3.360 + public Datum clone() {
3.361 + return new Datum();
3.362 + }
3.363 +
3.364 + Datum setNormalizedDate(int y, int i, int date) {
3.365 + return this;
3.366 + }
3.367 +
3.368 + void setTimeOfDay(int hrs, int min, int sec, int i) {
3.369 + }
3.370 +
3.371 + int getYear() {
3.372 + return 0;
3.373 + }
3.374 +
3.375 + void setDate(int year, int i, int mday) {
3.376 + }
3.377 +
3.378 + void setNormalizedYear(int i) {
3.379 + }
3.380 +
3.381 + int getMonth() {
3.382 + return 0;
3.383 + }
3.384 +
3.385 + int getNormalizedYear() {
3.386 + return 0;
3.387 + }
3.388 +
3.389 + void setMonth(int i) {
3.390 + }
3.391 +
3.392 + int getDayOfMonth() {
3.393 + return 0;
3.394 + }
3.395 +
3.396 + void setDayOfMonth(int date) {
3.397 + }
3.398 +
3.399 + int getDayOfWeek() {
3.400 + return 0;
3.401 + }
3.402 +
3.403 + int getHours() {
3.404 + return 0;
3.405 + }
3.406 +
3.407 + void setHours(int hours) {
3.408 + }
3.409 +
3.410 + int getMinutes() {
3.411 + return 0;
3.412 + }
3.413 +
3.414 + void setMinutes(int minutes) {
3.415 + }
3.416 +
3.417 + int getSeconds() {
3.418 + return 0;
3.419 + }
3.420 +
3.421 + void setSeconds(int seconds) {
3.422 + }
3.423 +
3.424 + boolean isNormalized() {
3.425 + return false;
3.426 + }
3.427 +
3.428 + Object getEra() {
3.429 + return this;
3.430 + }
3.431 +
3.432 + int getMillis() {
3.433 + return 0;
3.434 + }
3.435 +
3.436 + TimeZone getZone() {
3.437 + return TimeZone.NO_TIMEZONE;
3.438 + }
3.439 +
3.440 + int getZoneOffset() {
3.441 + return 0;
3.442 + }
3.443 + }
3.444 + }
3.445 }
4.1 --- a/rt/emul/compact/src/main/java/java/util/SimpleTimeZone.java Fri Oct 04 11:07:00 2013 +0200
4.2 +++ b/rt/emul/compact/src/main/java/java/util/SimpleTimeZone.java Fri Oct 04 12:01:56 2013 +0200
4.3 @@ -41,10 +41,7 @@
4.4 import java.io.ObjectInputStream;
4.5 import java.io.ObjectOutputStream;
4.6 import java.io.IOException;
4.7 -import sun.util.calendar.CalendarSystem;
4.8 -import sun.util.calendar.CalendarUtils;
4.9 -import sun.util.calendar.BaseCalendar;
4.10 -import sun.util.calendar.Gregorian;
4.11 +import java.util.Date.BaseCalendar;
4.12
4.13 /**
4.14 * <code>SimpleTimeZone</code> is a concrete subclass of <code>TimeZone</code>
4.15 @@ -555,9 +552,10 @@
4.16 }
4.17 }
4.18 }
4.19 - BaseCalendar cal = date >= GregorianCalendar.DEFAULT_GREGORIAN_CUTOVER ?
4.20 - gcal : (BaseCalendar) CalendarSystem.forName("julian");
4.21 - BaseCalendar.Date cdate = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.NO_TIMEZONE);
4.22 + BaseCalendar cal = gcal;
4.23 +// date >= GregorianCalendar.DEFAULT_GREGORIAN_CUTOVER ?
4.24 +// gcal : (BaseCalendar) CalendarSystem.forName("julian");
4.25 + BaseCalendar.Datum cdate = (BaseCalendar.Datum) cal.newCalendarDate(TimeZone.NO_TIMEZONE);
4.26 // Get the year in local time
4.27 cal.getCalendarDate(date + rawOffset, cdate);
4.28 int year = cdate.getNormalizedYear();
4.29 @@ -625,7 +623,7 @@
4.30 // y %= 28 also produces an equivalent year, but positive
4.31 // year numbers would be convenient to use the UNIX cal
4.32 // command.
4.33 - y = (int) CalendarUtils.mod((long) y, 28);
4.34 + y = (int) (long) y % 28;
4.35 }
4.36
4.37 // convert year to its 1-based month value
4.38 @@ -633,7 +631,7 @@
4.39
4.40 // First, calculate time as a Gregorian date.
4.41 BaseCalendar cal = gcal;
4.42 - BaseCalendar.Date cdate = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.NO_TIMEZONE);
4.43 + BaseCalendar.Datum cdate = (BaseCalendar.Datum) cal.newCalendarDate(TimeZone.NO_TIMEZONE);
4.44 cdate.setDate(y, m, day);
4.45 long time = cal.getTime(cdate); // normalize cdate
4.46 time += millis - rawOffset; // UTC time
4.47 @@ -644,12 +642,12 @@
4.48 // normalized year numbering is ..., -2 (BCE 2), -1 (BCE 1),
4.49 // 1, 2 ... which is different from the GregorianCalendar
4.50 // style year numbering (..., -1, 0 (BCE 1), 1, 2, ...).
4.51 - if (time < GregorianCalendar.DEFAULT_GREGORIAN_CUTOVER) {
4.52 - cal = (BaseCalendar) CalendarSystem.forName("julian");
4.53 - cdate = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.NO_TIMEZONE);
4.54 - cdate.setNormalizedDate(y, m, day);
4.55 - time = cal.getTime(cdate) + millis - rawOffset;
4.56 - }
4.57 +// if (time < GregorianCalendar.DEFAULT_GREGORIAN_CUTOVER) {
4.58 +// cal = (BaseCalendar) CalendarSystem.forName("julian");
4.59 +// cdate = (BaseCalendar.Datum) cal.newCalendarDate(TimeZone.NO_TIMEZONE);
4.60 +// cdate.setNormalizedDate(y, m, day);
4.61 +// time = cal.getTime(cdate) + millis - rawOffset;
4.62 +// }
4.63
4.64 if ((cdate.getNormalizedYear() != y)
4.65 || (cdate.getMonth() != m)
4.66 @@ -669,7 +667,7 @@
4.67 return getOffset(cal, cdate, y, time);
4.68 }
4.69
4.70 - private int getOffset(BaseCalendar cal, BaseCalendar.Date cdate, int year, long time) {
4.71 + private int getOffset(BaseCalendar cal, BaseCalendar.Datum cdate, int year, long time) {
4.72 synchronized (this) {
4.73 if (cacheStart != 0) {
4.74 if (time >= cacheStart && time < cacheEnd) {
4.75 @@ -721,7 +719,7 @@
4.76 return offset;
4.77 }
4.78
4.79 - private long getStart(BaseCalendar cal, BaseCalendar.Date cdate, int year) {
4.80 + private long getStart(BaseCalendar cal, BaseCalendar.Datum cdate, int year) {
4.81 int time = startTime;
4.82 if (startTimeMode != UTC_TIME) {
4.83 time -= rawOffset;
4.84 @@ -730,7 +728,7 @@
4.85 startDayOfWeek, time);
4.86 }
4.87
4.88 - private long getEnd(BaseCalendar cal, BaseCalendar.Date cdate, int year) {
4.89 + private long getEnd(BaseCalendar cal, BaseCalendar.Datum cdate, int year) {
4.90 int time = endTime;
4.91 if (endTimeMode != UTC_TIME) {
4.92 time -= rawOffset;
4.93 @@ -742,7 +740,7 @@
4.94 endDayOfWeek, time);
4.95 }
4.96
4.97 - private long getTransition(BaseCalendar cal, BaseCalendar.Date cdate,
4.98 + private long getTransition(BaseCalendar cal, BaseCalendar.Datum cdate,
4.99 int mode, int year, int month, int dayOfMonth,
4.100 int dayOfWeek, int timeOfDay) {
4.101 cdate.setNormalizedYear(year);
4.102 @@ -757,17 +755,17 @@
4.103 if (dayOfMonth < 0) {
4.104 cdate.setDayOfMonth(cal.getMonthLength(cdate));
4.105 }
4.106 - cdate = (BaseCalendar.Date) cal.getNthDayOfWeek(dayOfMonth, dayOfWeek, cdate);
4.107 + cdate = (BaseCalendar.Datum) cal.getNthDayOfWeek(dayOfMonth, dayOfWeek, cdate);
4.108 break;
4.109
4.110 case DOW_GE_DOM_MODE:
4.111 cdate.setDayOfMonth(dayOfMonth);
4.112 - cdate = (BaseCalendar.Date) cal.getNthDayOfWeek(1, dayOfWeek, cdate);
4.113 + cdate = (BaseCalendar.Datum) cal.getNthDayOfWeek(1, dayOfWeek, cdate);
4.114 break;
4.115
4.116 case DOW_LE_DOM_MODE:
4.117 cdate.setDayOfMonth(dayOfMonth);
4.118 - cdate = (BaseCalendar.Date) cal.getNthDayOfWeek(-1, dayOfWeek, cdate);
4.119 + cdate = (BaseCalendar.Datum) cal.getNthDayOfWeek(-1, dayOfWeek, cdate);
4.120 break;
4.121 }
4.122 return cal.getTime(cdate) + timeOfDay;
4.123 @@ -1196,7 +1194,7 @@
4.124 */
4.125 private int dstSavings;
4.126
4.127 - private static final Gregorian gcal = CalendarSystem.getGregorianCalendar();
4.128 + private static final BaseCalendar gcal = new BaseCalendar();//CalendarSystem.getGregorianCalendar();
4.129
4.130 /**
4.131 * Cache values representing a single period of daylight saving
4.132 @@ -1703,4 +1701,37 @@
4.133
4.134 serialVersionOnStream = currentSerialVersion;
4.135 }
4.136 +
4.137 + static final class GregorianCalendar {
4.138 + public static final int BC = 0;
4.139 +
4.140 + /**
4.141 + * Value of the {@link #ERA} field indicating the period before the
4.142 + * common era, the same value as {@link #BC}.
4.143 + *
4.144 + * @see #CE
4.145 + */
4.146 + static final int BCE = 0;
4.147 +
4.148 + /**
4.149 + * Value of the <code>ERA</code> field indicating the common era (Anno
4.150 + * Domini), also known as CE. The sequence of years at the transition
4.151 + * from <code>BC</code> to <code>AD</code> is ..., 2 BC, 1 BC, 1 AD, 2
4.152 + * AD,...
4.153 + *
4.154 + * @see #ERA
4.155 + */
4.156 + public static final int AD = 1;
4.157 +
4.158 + // The default value of gregorianCutover.
4.159 + static final long DEFAULT_GREGORIAN_CUTOVER = -12219292800000L;
4.160 + /**
4.161 + * Value of the {@link #ERA} field indicating
4.162 + * the common era, the same value as {@link #AD}.
4.163 + *
4.164 + * @see #BCE
4.165 + */
4.166 + static final int CE = 1;
4.167 +
4.168 + }
4.169 }
5.1 --- a/rt/emul/compact/src/main/java/java/util/TimeZone.java Fri Oct 04 11:07:00 2013 +0200
5.2 +++ b/rt/emul/compact/src/main/java/java/util/TimeZone.java Fri Oct 04 12:01:56 2013 +0200
5.3 @@ -43,10 +43,6 @@
5.4 import java.security.AccessController;
5.5 import java.security.PrivilegedAction;
5.6 import java.util.concurrent.ConcurrentHashMap;
5.7 -import sun.security.action.GetPropertyAction;
5.8 -import sun.util.TimeZoneNameUtility;
5.9 -import sun.util.calendar.ZoneInfo;
5.10 -import sun.util.calendar.ZoneInfoFile;
5.11
5.12 /**
5.13 * <code>TimeZone</code> represents a time zone offset, and also figures out daylight
5.14 @@ -411,7 +407,7 @@
5.15 if (daylight) {
5.16 offset += getDSTSavings();
5.17 }
5.18 - return ZoneInfoFile.toCustomID(offset);
5.19 + // return ZoneInfoFile.toCustomID(offset);
5.20 }
5.21
5.22 int index = daylight ? 3 : 1;
5.23 @@ -440,7 +436,7 @@
5.24 if (names != null) {
5.25 return names;
5.26 }
5.27 - names = TimeZoneNameUtility.retrieveDisplayNames(id, locale);
5.28 + names = null; // TimeZoneNameUtility.retrieveDisplayNames(id, locale);
5.29 if (names != null) {
5.30 perLocale.put(locale, names);
5.31 }
5.32 @@ -448,7 +444,7 @@
5.33 }
5.34 }
5.35
5.36 - String[] names = TimeZoneNameUtility.retrieveDisplayNames(id, locale);
5.37 + String[] names = null; // TimeZoneNameUtility.retrieveDisplayNames(id, locale);
5.38 if (names != null) {
5.39 Map<Locale, String[]> perLocale = new ConcurrentHashMap<Locale, String[]>();
5.40 perLocale.put(locale, names);
5.41 @@ -556,14 +552,15 @@
5.42 }
5.43
5.44 private static TimeZone getTimeZone(String ID, boolean fallback) {
5.45 - TimeZone tz = ZoneInfo.getTimeZone(ID);
5.46 - if (tz == null) {
5.47 - tz = parseCustomTimeZone(ID);
5.48 - if (tz == null && fallback) {
5.49 - tz = new ZoneInfo(GMT_ID, 0);
5.50 - }
5.51 - }
5.52 - return tz;
5.53 +// TimeZone tz = ZoneInfo.getTimeZone(ID);
5.54 +// if (tz == null) {
5.55 +// tz = parseCustomTimeZone(ID);
5.56 +// if (tz == null && fallback) {
5.57 +// tz = new ZoneInfo(GMT_ID, 0);
5.58 +// }
5.59 +// }
5.60 +// return tz;
5.61 + return TimeZone.NO_TIMEZONE;
5.62 }
5.63
5.64 /**
5.65 @@ -576,7 +573,7 @@
5.66 * @see #getRawOffset()
5.67 */
5.68 public static synchronized String[] getAvailableIDs(int rawOffset) {
5.69 - return ZoneInfo.getAvailableIDs(rawOffset);
5.70 + return new String[0];//ZoneInfo.getAvailableIDs(rawOffset);
5.71 }
5.72
5.73 /**
5.74 @@ -584,7 +581,7 @@
5.75 * @return an array of IDs.
5.76 */
5.77 public static synchronized String[] getAvailableIDs() {
5.78 - return ZoneInfo.getAvailableIDs();
5.79 + return new String[0];//return ZoneInfo.getAvailableIDs();
5.80 }
5.81
5.82 /**
5.83 @@ -615,12 +612,12 @@
5.84 * method doesn't create a clone.
5.85 */
5.86 static TimeZone getDefaultRef() {
5.87 - TimeZone defaultZone = defaultZoneTL.get();
5.88 + TimeZone defaultZone = null;//defaultZoneTL.get();
5.89 if (defaultZone == null) {
5.90 defaultZone = defaultTimeZone;
5.91 if (defaultZone == null) {
5.92 // Need to initialize the default time zone.
5.93 - defaultZone = setDefaultZone();
5.94 + defaultZone = TimeZone.NO_TIMEZONE;
5.95 assert defaultZone != null;
5.96 }
5.97 }
5.98 @@ -628,68 +625,8 @@
5.99 return defaultZone;
5.100 }
5.101
5.102 - private static synchronized TimeZone setDefaultZone() {
5.103 - TimeZone tz = null;
5.104 - // get the time zone ID from the system properties
5.105 - String zoneID = AccessController.doPrivileged(
5.106 - new GetPropertyAction("user.timezone"));
5.107 -
5.108 - // if the time zone ID is not set (yet), perform the
5.109 - // platform to Java time zone ID mapping.
5.110 - if (zoneID == null || zoneID.equals("")) {
5.111 - String country = AccessController.doPrivileged(
5.112 - new GetPropertyAction("user.country"));
5.113 - String javaHome = AccessController.doPrivileged(
5.114 - new GetPropertyAction("java.home"));
5.115 - try {
5.116 - zoneID = getSystemTimeZoneID(javaHome, country);
5.117 - if (zoneID == null) {
5.118 - zoneID = GMT_ID;
5.119 - }
5.120 - } catch (NullPointerException e) {
5.121 - zoneID = GMT_ID;
5.122 - }
5.123 - }
5.124 -
5.125 - // Get the time zone for zoneID. But not fall back to
5.126 - // "GMT" here.
5.127 - tz = getTimeZone(zoneID, false);
5.128 -
5.129 - if (tz == null) {
5.130 - // If the given zone ID is unknown in Java, try to
5.131 - // get the GMT-offset-based time zone ID,
5.132 - // a.k.a. custom time zone ID (e.g., "GMT-08:00").
5.133 - String gmtOffsetID = getSystemGMTOffsetID();
5.134 - if (gmtOffsetID != null) {
5.135 - zoneID = gmtOffsetID;
5.136 - }
5.137 - tz = getTimeZone(zoneID, true);
5.138 - }
5.139 - assert tz != null;
5.140 -
5.141 - final String id = zoneID;
5.142 - AccessController.doPrivileged(new PrivilegedAction<Object>() {
5.143 - public Object run() {
5.144 - System.setProperty("user.timezone", id);
5.145 - return null;
5.146 - }
5.147 - });
5.148 -
5.149 - defaultTimeZone = tz;
5.150 - return tz;
5.151 - }
5.152 -
5.153 private static boolean hasPermission() {
5.154 - boolean hasPermission = true;
5.155 - SecurityManager sm = System.getSecurityManager();
5.156 - if (sm != null) {
5.157 - try {
5.158 - sm.checkPermission(new PropertyPermission
5.159 - ("user.timezone", "write"));
5.160 - } catch (SecurityException e) {
5.161 - hasPermission = false;
5.162 - }
5.163 - }
5.164 + boolean hasPermission = false;
5.165 return hasPermission;
5.166 }
5.167
5.168 @@ -706,10 +643,10 @@
5.169 if (hasPermission()) {
5.170 synchronized (TimeZone.class) {
5.171 defaultTimeZone = zone;
5.172 - defaultZoneTL.set(null);
5.173 + // defaultZoneTL.set(null);
5.174 }
5.175 } else {
5.176 - defaultZoneTL.set(zone);
5.177 + //defaultZoneTL.set(zone);
5.178 }
5.179 }
5.180
5.181 @@ -760,8 +697,6 @@
5.182 */
5.183 private String ID;
5.184 private static volatile TimeZone defaultTimeZone;
5.185 - private static final InheritableThreadLocal<TimeZone> defaultZoneTL
5.186 - = new InheritableThreadLocal<TimeZone>();
5.187
5.188 static final String GMT_ID = "GMT";
5.189 private static final int GMT_ID_LENGTH = 3;
5.190 @@ -775,90 +710,6 @@
5.191 * no daylight saving time, or null if the id cannot be parsed.
5.192 */
5.193 private static final TimeZone parseCustomTimeZone(String id) {
5.194 - int length;
5.195 -
5.196 - // Error if the length of id isn't long enough or id doesn't
5.197 - // start with "GMT".
5.198 - if ((length = id.length()) < (GMT_ID_LENGTH + 2) ||
5.199 - id.indexOf(GMT_ID) != 0) {
5.200 - return null;
5.201 - }
5.202 -
5.203 - ZoneInfo zi;
5.204 -
5.205 - // First, we try to find it in the cache with the given
5.206 - // id. Even the id is not normalized, the returned ZoneInfo
5.207 - // should have its normalized id.
5.208 - zi = ZoneInfoFile.getZoneInfo(id);
5.209 - if (zi != null) {
5.210 - return zi;
5.211 - }
5.212 -
5.213 - int index = GMT_ID_LENGTH;
5.214 - boolean negative = false;
5.215 - char c = id.charAt(index++);
5.216 - if (c == '-') {
5.217 - negative = true;
5.218 - } else if (c != '+') {
5.219 - return null;
5.220 - }
5.221 -
5.222 - int hours = 0;
5.223 - int num = 0;
5.224 - int countDelim = 0;
5.225 - int len = 0;
5.226 - while (index < length) {
5.227 - c = id.charAt(index++);
5.228 - if (c == ':') {
5.229 - if (countDelim > 0) {
5.230 - return null;
5.231 - }
5.232 - if (len > 2) {
5.233 - return null;
5.234 - }
5.235 - hours = num;
5.236 - countDelim++;
5.237 - num = 0;
5.238 - len = 0;
5.239 - continue;
5.240 - }
5.241 - if (c < '0' || c > '9') {
5.242 - return null;
5.243 - }
5.244 - num = num * 10 + (c - '0');
5.245 - len++;
5.246 - }
5.247 - if (index != length) {
5.248 - return null;
5.249 - }
5.250 - if (countDelim == 0) {
5.251 - if (len <= 2) {
5.252 - hours = num;
5.253 - num = 0;
5.254 - } else {
5.255 - hours = num / 100;
5.256 - num %= 100;
5.257 - }
5.258 - } else {
5.259 - if (len != 2) {
5.260 - return null;
5.261 - }
5.262 - }
5.263 - if (hours > 23 || num > 59) {
5.264 - return null;
5.265 - }
5.266 - int gmtOffset = (hours * 60 + num) * 60 * 1000;
5.267 -
5.268 - if (gmtOffset == 0) {
5.269 - zi = ZoneInfoFile.getZoneInfo(GMT_ID);
5.270 - if (negative) {
5.271 - zi.setID("GMT-00:00");
5.272 - } else {
5.273 - zi.setID("GMT+00:00");
5.274 - }
5.275 - } else {
5.276 - zi = ZoneInfoFile.getCustomTimeZone(id, negative ? -gmtOffset : gmtOffset);
5.277 - }
5.278 - return zi;
5.279 + return null;
5.280 }
5.281 }