< prev index next >

src/java.base/share/classes/java/util/JapaneseImperialCalendar.java

Print this page




 234         292278994,      // YEAR
 235         DECEMBER,       // MONTH
 236         53,             // WEEK_OF_YEAR
 237         6,              // WEEK_OF_MONTH
 238         31,             // DAY_OF_MONTH
 239         366,            // DAY_OF_YEAR
 240         SATURDAY,       // DAY_OF_WEEK
 241         6,              // DAY_OF_WEEK_IN
 242         PM,             // AM_PM
 243         11,             // HOUR
 244         23,             // HOUR_OF_DAY
 245         59,             // MINUTE
 246         59,             // SECOND
 247         999,            // MILLISECOND
 248         14*ONE_HOUR,    // ZONE_OFFSET
 249         2*ONE_HOUR      // DST_OFFSET (double summer time)
 250     };
 251 
 252     // Proclaim serialization compatibility with JDK 1.6
 253     @SuppressWarnings("FieldNameHidesFieldInSuperclass")

 254     private static final long serialVersionUID = -3364572813905467929L;
 255 
 256     static {
 257         Era[] es = jcal.getEras();
 258         int length = es.length + 1;
 259         eras = new Era[length];
 260         sinceFixedDates = new long[length];
 261 
 262         // eras[BEFORE_MEIJI] and sinceFixedDate[BEFORE_MEIJI] are the
 263         // same as Gregorian.
 264         int index = BEFORE_MEIJI;
 265         int current = index;
 266         sinceFixedDates[index] = gcal.getFixedDate(BEFORE_MEIJI_ERA.getSinceDate());
 267         eras[index++] = BEFORE_MEIJI_ERA;
 268         for (Era e : es) {
 269             if(e.getSince(TimeZone.NO_TIMEZONE) < System.currentTimeMillis()) {
 270                 current = index;
 271             }
 272             CalendarDate d = e.getSinceDate();
 273             sinceFixedDates[index] = gcal.getFixedDate(d);


2374         if (n > max) {
2375             n -= range;
2376         } else if (n < min) {
2377             n += range;
2378         }
2379         assert n >= min && n <= max;
2380         return n;
2381     }
2382 
2383     /**
2384      * Returns the ERA.  We need a special method for this because the
2385      * default ERA is the current era, but a zero (unset) ERA means before Meiji.
2386      */
2387     private int internalGetEra() {
2388         return isSet(ERA) ? internalGet(ERA) : currentEra;
2389     }
2390 
2391     /**
2392      * Updates internal state.
2393      */

2394     private void readObject(ObjectInputStream stream)
2395             throws IOException, ClassNotFoundException {
2396         stream.defaultReadObject();
2397         if (jdate == null) {
2398             jdate = jcal.newCalendarDate(getZone());
2399             cachedFixedDate = Long.MIN_VALUE;
2400         }
2401     }
2402 }


 234         292278994,      // YEAR
 235         DECEMBER,       // MONTH
 236         53,             // WEEK_OF_YEAR
 237         6,              // WEEK_OF_MONTH
 238         31,             // DAY_OF_MONTH
 239         366,            // DAY_OF_YEAR
 240         SATURDAY,       // DAY_OF_WEEK
 241         6,              // DAY_OF_WEEK_IN
 242         PM,             // AM_PM
 243         11,             // HOUR
 244         23,             // HOUR_OF_DAY
 245         59,             // MINUTE
 246         59,             // SECOND
 247         999,            // MILLISECOND
 248         14*ONE_HOUR,    // ZONE_OFFSET
 249         2*ONE_HOUR      // DST_OFFSET (double summer time)
 250     };
 251 
 252     // Proclaim serialization compatibility with JDK 1.6
 253     @SuppressWarnings("FieldNameHidesFieldInSuperclass")
 254     @java.io.Serial
 255     private static final long serialVersionUID = -3364572813905467929L;
 256 
 257     static {
 258         Era[] es = jcal.getEras();
 259         int length = es.length + 1;
 260         eras = new Era[length];
 261         sinceFixedDates = new long[length];
 262 
 263         // eras[BEFORE_MEIJI] and sinceFixedDate[BEFORE_MEIJI] are the
 264         // same as Gregorian.
 265         int index = BEFORE_MEIJI;
 266         int current = index;
 267         sinceFixedDates[index] = gcal.getFixedDate(BEFORE_MEIJI_ERA.getSinceDate());
 268         eras[index++] = BEFORE_MEIJI_ERA;
 269         for (Era e : es) {
 270             if(e.getSince(TimeZone.NO_TIMEZONE) < System.currentTimeMillis()) {
 271                 current = index;
 272             }
 273             CalendarDate d = e.getSinceDate();
 274             sinceFixedDates[index] = gcal.getFixedDate(d);


2375         if (n > max) {
2376             n -= range;
2377         } else if (n < min) {
2378             n += range;
2379         }
2380         assert n >= min && n <= max;
2381         return n;
2382     }
2383 
2384     /**
2385      * Returns the ERA.  We need a special method for this because the
2386      * default ERA is the current era, but a zero (unset) ERA means before Meiji.
2387      */
2388     private int internalGetEra() {
2389         return isSet(ERA) ? internalGet(ERA) : currentEra;
2390     }
2391 
2392     /**
2393      * Updates internal state.
2394      */
2395     @java.io.Serial
2396     private void readObject(ObjectInputStream stream)
2397             throws IOException, ClassNotFoundException {
2398         stream.defaultReadObject();
2399         if (jdate == null) {
2400             jdate = jcal.newCalendarDate(getZone());
2401             cachedFixedDate = Long.MIN_VALUE;
2402         }
2403     }
2404 }
< prev index next >