1.1 --- a/rt/emul/compact/src/main/java/java/util/SimpleTimeZone.java Thu Oct 03 15:40:35 2013 +0200
1.2 +++ b/rt/emul/compact/src/main/java/java/util/SimpleTimeZone.java Fri Oct 04 12:01:56 2013 +0200
1.3 @@ -41,10 +41,7 @@
1.4 import java.io.ObjectInputStream;
1.5 import java.io.ObjectOutputStream;
1.6 import java.io.IOException;
1.7 -import sun.util.calendar.CalendarSystem;
1.8 -import sun.util.calendar.CalendarUtils;
1.9 -import sun.util.calendar.BaseCalendar;
1.10 -import sun.util.calendar.Gregorian;
1.11 +import java.util.Date.BaseCalendar;
1.12
1.13 /**
1.14 * <code>SimpleTimeZone</code> is a concrete subclass of <code>TimeZone</code>
1.15 @@ -555,9 +552,10 @@
1.16 }
1.17 }
1.18 }
1.19 - BaseCalendar cal = date >= GregorianCalendar.DEFAULT_GREGORIAN_CUTOVER ?
1.20 - gcal : (BaseCalendar) CalendarSystem.forName("julian");
1.21 - BaseCalendar.Date cdate = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.NO_TIMEZONE);
1.22 + BaseCalendar cal = gcal;
1.23 +// date >= GregorianCalendar.DEFAULT_GREGORIAN_CUTOVER ?
1.24 +// gcal : (BaseCalendar) CalendarSystem.forName("julian");
1.25 + BaseCalendar.Datum cdate = (BaseCalendar.Datum) cal.newCalendarDate(TimeZone.NO_TIMEZONE);
1.26 // Get the year in local time
1.27 cal.getCalendarDate(date + rawOffset, cdate);
1.28 int year = cdate.getNormalizedYear();
1.29 @@ -625,7 +623,7 @@
1.30 // y %= 28 also produces an equivalent year, but positive
1.31 // year numbers would be convenient to use the UNIX cal
1.32 // command.
1.33 - y = (int) CalendarUtils.mod((long) y, 28);
1.34 + y = (int) (long) y % 28;
1.35 }
1.36
1.37 // convert year to its 1-based month value
1.38 @@ -633,7 +631,7 @@
1.39
1.40 // First, calculate time as a Gregorian date.
1.41 BaseCalendar cal = gcal;
1.42 - BaseCalendar.Date cdate = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.NO_TIMEZONE);
1.43 + BaseCalendar.Datum cdate = (BaseCalendar.Datum) cal.newCalendarDate(TimeZone.NO_TIMEZONE);
1.44 cdate.setDate(y, m, day);
1.45 long time = cal.getTime(cdate); // normalize cdate
1.46 time += millis - rawOffset; // UTC time
1.47 @@ -644,12 +642,12 @@
1.48 // normalized year numbering is ..., -2 (BCE 2), -1 (BCE 1),
1.49 // 1, 2 ... which is different from the GregorianCalendar
1.50 // style year numbering (..., -1, 0 (BCE 1), 1, 2, ...).
1.51 - if (time < GregorianCalendar.DEFAULT_GREGORIAN_CUTOVER) {
1.52 - cal = (BaseCalendar) CalendarSystem.forName("julian");
1.53 - cdate = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.NO_TIMEZONE);
1.54 - cdate.setNormalizedDate(y, m, day);
1.55 - time = cal.getTime(cdate) + millis - rawOffset;
1.56 - }
1.57 +// if (time < GregorianCalendar.DEFAULT_GREGORIAN_CUTOVER) {
1.58 +// cal = (BaseCalendar) CalendarSystem.forName("julian");
1.59 +// cdate = (BaseCalendar.Datum) cal.newCalendarDate(TimeZone.NO_TIMEZONE);
1.60 +// cdate.setNormalizedDate(y, m, day);
1.61 +// time = cal.getTime(cdate) + millis - rawOffset;
1.62 +// }
1.63
1.64 if ((cdate.getNormalizedYear() != y)
1.65 || (cdate.getMonth() != m)
1.66 @@ -669,7 +667,7 @@
1.67 return getOffset(cal, cdate, y, time);
1.68 }
1.69
1.70 - private int getOffset(BaseCalendar cal, BaseCalendar.Date cdate, int year, long time) {
1.71 + private int getOffset(BaseCalendar cal, BaseCalendar.Datum cdate, int year, long time) {
1.72 synchronized (this) {
1.73 if (cacheStart != 0) {
1.74 if (time >= cacheStart && time < cacheEnd) {
1.75 @@ -721,7 +719,7 @@
1.76 return offset;
1.77 }
1.78
1.79 - private long getStart(BaseCalendar cal, BaseCalendar.Date cdate, int year) {
1.80 + private long getStart(BaseCalendar cal, BaseCalendar.Datum cdate, int year) {
1.81 int time = startTime;
1.82 if (startTimeMode != UTC_TIME) {
1.83 time -= rawOffset;
1.84 @@ -730,7 +728,7 @@
1.85 startDayOfWeek, time);
1.86 }
1.87
1.88 - private long getEnd(BaseCalendar cal, BaseCalendar.Date cdate, int year) {
1.89 + private long getEnd(BaseCalendar cal, BaseCalendar.Datum cdate, int year) {
1.90 int time = endTime;
1.91 if (endTimeMode != UTC_TIME) {
1.92 time -= rawOffset;
1.93 @@ -742,7 +740,7 @@
1.94 endDayOfWeek, time);
1.95 }
1.96
1.97 - private long getTransition(BaseCalendar cal, BaseCalendar.Date cdate,
1.98 + private long getTransition(BaseCalendar cal, BaseCalendar.Datum cdate,
1.99 int mode, int year, int month, int dayOfMonth,
1.100 int dayOfWeek, int timeOfDay) {
1.101 cdate.setNormalizedYear(year);
1.102 @@ -757,17 +755,17 @@
1.103 if (dayOfMonth < 0) {
1.104 cdate.setDayOfMonth(cal.getMonthLength(cdate));
1.105 }
1.106 - cdate = (BaseCalendar.Date) cal.getNthDayOfWeek(dayOfMonth, dayOfWeek, cdate);
1.107 + cdate = (BaseCalendar.Datum) cal.getNthDayOfWeek(dayOfMonth, dayOfWeek, cdate);
1.108 break;
1.109
1.110 case DOW_GE_DOM_MODE:
1.111 cdate.setDayOfMonth(dayOfMonth);
1.112 - cdate = (BaseCalendar.Date) cal.getNthDayOfWeek(1, dayOfWeek, cdate);
1.113 + cdate = (BaseCalendar.Datum) cal.getNthDayOfWeek(1, dayOfWeek, cdate);
1.114 break;
1.115
1.116 case DOW_LE_DOM_MODE:
1.117 cdate.setDayOfMonth(dayOfMonth);
1.118 - cdate = (BaseCalendar.Date) cal.getNthDayOfWeek(-1, dayOfWeek, cdate);
1.119 + cdate = (BaseCalendar.Datum) cal.getNthDayOfWeek(-1, dayOfWeek, cdate);
1.120 break;
1.121 }
1.122 return cal.getTime(cdate) + timeOfDay;
1.123 @@ -1196,7 +1194,7 @@
1.124 */
1.125 private int dstSavings;
1.126
1.127 - private static final Gregorian gcal = CalendarSystem.getGregorianCalendar();
1.128 + private static final BaseCalendar gcal = new BaseCalendar();//CalendarSystem.getGregorianCalendar();
1.129
1.130 /**
1.131 * Cache values representing a single period of daylight saving
1.132 @@ -1703,4 +1701,37 @@
1.133
1.134 serialVersionOnStream = currentSerialVersion;
1.135 }
1.136 +
1.137 + static final class GregorianCalendar {
1.138 + public static final int BC = 0;
1.139 +
1.140 + /**
1.141 + * Value of the {@link #ERA} field indicating the period before the
1.142 + * common era, the same value as {@link #BC}.
1.143 + *
1.144 + * @see #CE
1.145 + */
1.146 + static final int BCE = 0;
1.147 +
1.148 + /**
1.149 + * Value of the <code>ERA</code> field indicating the common era (Anno
1.150 + * Domini), also known as CE. The sequence of years at the transition
1.151 + * from <code>BC</code> to <code>AD</code> is ..., 2 BC, 1 BC, 1 AD, 2
1.152 + * AD,...
1.153 + *
1.154 + * @see #ERA
1.155 + */
1.156 + public static final int AD = 1;
1.157 +
1.158 + // The default value of gregorianCutover.
1.159 + static final long DEFAULT_GREGORIAN_CUTOVER = -12219292800000L;
1.160 + /**
1.161 + * Value of the {@link #ERA} field indicating
1.162 + * the common era, the same value as {@link #AD}.
1.163 + *
1.164 + * @see #BCE
1.165 + */
1.166 + static final int CE = 1;
1.167 +
1.168 + }
1.169 }