1// © 2016 and later: Unicode, Inc. and others. 2// License & terms of use: http://www.unicode.org/copyright.html#License 3/* 4 ******************************************************************************* 5 * Copyright (C) 1996-2014, International Business Machines Corporation and * 6 * others. All Rights Reserved. * 7 ******************************************************************************* 8 */ 9package com.ibm.icu.util; 10import java.util.Date; 11import java.util.Locale; 12 13/** 14 * <code>JapaneseCalendar</code> is a subclass of <code>GregorianCalendar</code> 15 * that numbers years and eras based on the reigns of the Japanese emperors. 16 * The Japanese calendar is identical to the Gregorian calendar in all respects 17 * except for the year and era. The ascension of each emperor to the throne 18 * begins a new era, and the years of that era are numbered starting with the 19 * year of ascension as year 1. 20 * <p> 21 * Note that in the year of an imperial ascension, there are two possible sets 22 * of year and era values: that for the old era and for the new. For example, a 23 * new era began on January 7, 1989 AD. Strictly speaking, the first six days 24 * of that year were in the Showa era, e.g. "January 6, 64 Showa", while the rest 25 * of the year was in the Heisei era, e.g. "January 7, 1 Heisei". This class 26 * handles this distinction correctly when computing dates. However, in lenient 27 * mode either form of date is acceptable as input. 28 * <p> 29 * In modern times, eras have started on January 8, 1868 AD, Gregorian (Meiji), 30 * July 30, 1912 (Taisho), December 25, 1926 (Showa), and January 7, 1989 (Heisei). Constants 31 * for these eras, suitable for use in the <code>ERA</code> field, are provided 32 * in this class. Note that the <em>number</em> used for each era is more or 33 * less arbitrary. Currently, the era starting in 1053 AD is era #0; however this 34 * may change in the future as we add more historical data. Use the predefined 35 * constants rather than using actual, absolute numbers. 36 * <p> 37 * This class should not be subclassed.</p> 38 * <p> 39 * JapaneseCalendar usually should be instantiated using 40 * {@link com.ibm.icu.util.Calendar#getInstance(ULocale)} passing in a <code>ULocale</code> 41 * with the tag <code>"@calendar=japanese"</code>.</p> 42 * 43 * @see com.ibm.icu.util.GregorianCalendar 44 * @see com.ibm.icu.util.Calendar 45 * 46 * @author Laura Werner 47 * @author Alan Liu 48 * @stable ICU 2.8 49 */ 50public class JapaneseCalendar extends GregorianCalendar { 51 // jdk1.4.2 serialver 52 private static final long serialVersionUID = -2977189902603704691L; 53 54 //------------------------------------------------------------------------- 55 // Constructors... 56 //------------------------------------------------------------------------- 57 58 /** 59 * Constructs a default <code>JapaneseCalendar</code> using the current time 60 * in the default time zone with the default locale. 61 * @stable ICU 2.8 62 */ 63 public JapaneseCalendar() { 64 super(); 65 } 66 67 /** 68 * Constructs a <code>JapaneseCalendar</code> based on the current time 69 * in the given time zone with the default locale. 70 * @param zone the given time zone. 71 * @stable ICU 2.8 72 */ 73 public JapaneseCalendar(TimeZone zone) { 74 super(zone); 75 } 76 77 /** 78 * Constructs a <code>JapaneseCalendar</code> based on the current time 79 * in the default time zone with the given locale. 80 * @param aLocale the given locale. 81 * @stable ICU 2.8 82 */ 83 public JapaneseCalendar(Locale aLocale) { 84 super(aLocale); 85 } 86 87 /** 88 * Constructs a <code>JapaneseCalendar</code> based on the current time 89 * in the default time zone with the given locale. 90 * @param locale the given ulocale. 91 * @stable ICU 3.2 92 */ 93 public JapaneseCalendar(ULocale locale) { 94 super(locale); 95 } 96 97 /** 98 * Constructs a <code>JapaneseCalendar</code> based on the current time 99 * in the given time zone with the given locale. 100 * 101 * @param zone the given time zone. 102 * 103 * @param aLocale the given locale. 104 * @stable ICU 2.8 105 */ 106 public JapaneseCalendar(TimeZone zone, Locale aLocale) { 107 super(zone, aLocale); 108 } 109 110 /** 111 * Constructs a <code>JapaneseCalendar</code> based on the current time 112 * in the given time zone with the given locale. 113 * 114 * @param zone the given time zone. 115 * 116 * @param locale the given ulocale. 117 * @stable ICU 3.2 118 */ 119 public JapaneseCalendar(TimeZone zone, ULocale locale) { 120 super(zone, locale); 121 } 122 123 /** 124 * Constructs a <code>JapaneseCalendar</code> with the given date set 125 * in the default time zone with the default locale. 126 * 127 * @param date The date to which the new calendar is set. 128 * @stable ICU 2.8 129 */ 130 public JapaneseCalendar(Date date) { 131 this(); 132 setTime(date); 133 } 134 135 /** 136 * Constructs a <code>JapaneseCalendar</code> with the given date set 137 * in the default time zone with the default locale. 138 * 139 * @param era The imperial era used to set the calendar's {@link #ERA ERA} field. 140 * Eras are numbered starting with the Tenki era, which 141 * began in 1053 AD Gregorian, as era zero. Recent 142 * eras can be specified using the constants 143 * {@link #MEIJI} (which started in 1868 AD), 144 * {@link #TAISHO} (1912 AD), 145 * {@link #SHOWA} (1926 AD), and 146 * {@link #HEISEI} (1989 AD). 147 * 148 * @param year The value used to set the calendar's {@link #YEAR YEAR} field, 149 * in terms of the era. 150 * 151 * @param month The value used to set the calendar's {@link #MONTH MONTH} field. 152 * The value is 0-based. e.g., 0 for January. 153 * 154 * @param date The value used to set the calendar's DATE field. 155 * @stable ICU 2.8 156 */ 157 public JapaneseCalendar(int era, int year, int month, int date) { 158 super(year, month, date); 159 set(ERA, era); 160 } 161 162 /** 163 * Constructs a <code>JapaneseCalendar</code> with the given date set 164 * in the default time zone with the default locale. 165 * 166 * @param year The value used to set the calendar's {@link #YEAR YEAR} field, 167 * in the era Heisei, the most current at the time this 168 * class was last updated. 169 * 170 * @param month The value used to set the calendar's {@link #MONTH MONTH} field. 171 * The value is 0-based. e.g., 0 for January. 172 * 173 * @param date The value used to set the calendar's {@link #DATE DATE} field. 174 * @stable ICU 2.8 175 */ 176 public JapaneseCalendar(int year, int month, int date) { 177 super(year, month, date); 178 set(ERA, CURRENT_ERA); 179 } 180 181 /** 182 * Constructs a <code>JapaneseCalendar</code> with the given date 183 * and time set for the default time zone with the default locale. 184 * 185 * @param year The value used to set the calendar's {@link #YEAR YEAR} time field, 186 * in the era Heisei, the most current at the time of this 187 * writing. 188 * 189 * @param month The value used to set the calendar's {@link #MONTH MONTH} time field. 190 * The value is 0-based. e.g., 0 for January. 191 * 192 * @param date The value used to set the calendar's {@link #DATE DATE} time field. 193 * 194 * @param hour The value used to set the calendar's {@link #HOUR_OF_DAY HOUR_OF_DAY} time field. 195 * 196 * @param minute The value used to set the calendar's {@link #MINUTE MINUTE} time field. 197 * 198 * @param second The value used to set the calendar's {@link #SECOND SECOND} time field. 199 * @stable ICU 2.8 200 */ 201 public JapaneseCalendar(int year, int month, int date, int hour, 202 int minute, int second) 203 { 204 super(year, month, date, hour, minute, second); 205 set(ERA, CURRENT_ERA); 206 } 207 208 //------------------------------------------------------------------------- 209 210 // Use 1970 as the default value of EXTENDED_YEAR 211 private static final int GREGORIAN_EPOCH = 1970; 212 213 /** 214 * @stable ICU 2.8 215 */ 216 protected int handleGetExtendedYear() { 217 // EXTENDED_YEAR in JapaneseCalendar is a Gregorian year 218 // The default value of EXTENDED_YEAR is 1970 (Showa 45) 219 int year; 220 if (newerField(EXTENDED_YEAR, YEAR) == EXTENDED_YEAR && 221 newerField(EXTENDED_YEAR, ERA) == EXTENDED_YEAR) { 222 year = internalGet(EXTENDED_YEAR, GREGORIAN_EPOCH); 223 } else { 224 // extended year is a gregorian year, where 1 = 1AD, 0 = 1BC, -1 = 2BC, etc 225 year = internalGet(YEAR, 1) // pin to minimum of year 1 (first year) 226 + ERAS[internalGet(ERA, CURRENT_ERA) * 3] // add gregorian starting year 227 - 1; // Subtract one because year starts at 1 228 } 229 return year; 230 } 231 232 /** 233 * Called by handleComputeJulianDay. Returns the default month (0-based) for the year, 234 * taking year and era into account. Defaults to 0 (JANUARY) for Gregorian. 235 * @param extendedYear the extendedYear, as returned by handleGetExtendedYear 236 * @return the default month 237 * @provisional ICU 3.6 238 * @draft ICU 3.6 (retain) 239 * @see #MONTH 240 */ 241 protected int getDefaultMonthInYear(int extendedYear) 242 { 243 int era = internalGet(ERA, CURRENT_ERA); 244 //computeFields(status); // No need to compute fields here - expect the caller already did so. 245 246 // Find out if we are at the edge of an era 247 if(extendedYear == ERAS[era*3]) { 248 return ERAS[(era*3)+1] // month.. 249 -1; // return 0-based month 250 } else { 251 return super.getDefaultMonthInYear(extendedYear); 252 } 253 } 254 255 /** 256 * Called by handleComputeJulianDay. Returns the default day (1-based) for the month, 257 * taking currently-set year and era into account. Defaults to 1 for Gregorian. 258 * @param extendedYear the extendedYear, as returned by handleGetExtendedYear 259 * @param month the month, as returned by getDefaultMonthInYear 260 * @return the default day of the month 261 * @draft ICU 3.6 (retain) 262 * @provisional ICU 3.6 263 * @see #DAY_OF_MONTH 264 */ 265 protected int getDefaultDayInMonth(int extendedYear, int month) { 266 int era = internalGet(ERA, CURRENT_ERA); 267 268 if(extendedYear == ERAS[era*3]) { // if it is year 1.. 269 if(month == ((ERAS[(era*3)+1])-1)) { // if it is the emperor's first month.. 270 return ERAS[(era*3)+2]; // return the D_O_M of acession 271 } 272 } 273 274 return super.getDefaultDayInMonth(extendedYear, month); 275 } 276 277 /** 278 * @stable ICU 2.8 279 */ 280 protected void handleComputeFields(int julianDay) { 281 super.handleComputeFields(julianDay); 282 int year = internalGet(EXTENDED_YEAR); 283 284 int low = 0; 285 286 // Short circuit for recent years. Most modern computations will 287 // occur in the current era and won't require the binary search. 288 // Note that if the year is == the current era year, then we use 289 // the binary search to handle the month/dom comparison. 290 if (year > ERAS[ERAS.length - 3]) { 291 low = CURRENT_ERA; 292 } else { 293 // Binary search 294 int high = ERAS.length / 3; 295 296 while (low < high - 1) { 297 int i = (low + high) / 2; 298 int diff = year - ERAS[i*3]; 299 300 // If years are the same, then compare the months, and if those 301 // are the same, compare days of month. In the ERAS array 302 // months are 1-based for easier maintenance. 303 if (diff == 0) { 304 diff = internalGet(MONTH) - (ERAS[i*3 + 1] - 1); 305 if (diff == 0) { 306 diff = internalGet(DAY_OF_MONTH) - ERAS[i*3 + 2]; 307 } 308 } 309 if (diff >= 0) { 310 low = i; 311 } else { 312 high = i; 313 } 314 } 315 } 316 317 // Now we've found the last era that starts before this date, so 318 // adjust the year to count from the start of that era. Note that 319 // all dates before the first era will fall into the first era by 320 // the algorithm. 321 internalSet(ERA, low); 322 internalSet(YEAR, year - ERAS[low*3] + 1); 323 } 324 325 private static final int[] ERAS = { 326 // Gregorian date of each emperor's ascension 327 // Years are AD, months are 1-based. 328 // Year Month Day 329 645, 6, 19, // Taika 330 650, 2, 15, // Hakuchi 331 672, 1, 1, // Hakuho 332 686, 7, 20, // Shucho 333 701, 3, 21, // Taiho 334 704, 5, 10, // Keiun 335 708, 1, 11, // Wado 336 715, 9, 2, // Reiki 337 717, 11, 17, // Yoro 338 724, 2, 4, // Jinki 339 729, 8, 5, // Tempyo 340 749, 4, 14, // Tempyo-kampo 341 749, 7, 2, // Tempyo-shoho 342 757, 8, 18, // Tempyo-hoji 343 765, 1, 7, // Tempho-jingo 344 767, 8, 16, // Jingo-keiun 345 770, 10, 1, // Hoki 346 781, 1, 1, // Ten-o 347 782, 8, 19, // Enryaku 348 806, 5, 18, // Daido 349 810, 9, 19, // Konin 350 824, 1, 5, // Tencho 351 834, 1, 3, // Showa 352 848, 6, 13, // Kajo 353 851, 4, 28, // Ninju 354 854, 11, 30, // Saiko 355 857, 2, 21, // Tennan 356 859, 4, 15, // Jogan 357 877, 4, 16, // Genkei 358 885, 2, 21, // Ninna 359 889, 4, 27, // Kampyo 360 898, 4, 26, // Shotai 361 901, 7, 15, // Engi 362 923, 4, 11, // Encho 363 931, 4, 26, // Shohei 364 938, 5, 22, // Tengyo 365 947, 4, 22, // Tenryaku 366 957, 10, 27, // Tentoku 367 961, 2, 16, // Owa 368 964, 7, 10, // Koho 369 968, 8, 13, // Anna 370 970, 3, 25, // Tenroku 371 973, 12, 20, // Ten-en 372 976, 7, 13, // Jogen 373 978, 11, 29, // Tengen 374 983, 4, 15, // Eikan 375 985, 4, 27, // Kanna 376 987, 4, 5, // Ei-en 377 989, 8, 8, // Eiso 378 990, 11, 7, // Shoryaku 379 995, 2, 22, // Chotoku 380 999, 1, 13, // Choho 381 1004, 7, 20, // Kanko 382 1012, 12, 25, // Chowa 383 1017, 4, 23, // Kannin 384 1021, 2, 2, // Jian 385 1024, 7, 13, // Manju 386 1028, 7, 25, // Chogen 387 1037, 4, 21, // Choryaku 388 1040, 11, 10, // Chokyu 389 1044, 11, 24, // Kantoku 390 1046, 4, 14, // Eisho 391 1053, 1, 11, // Tengi 392 1058, 8, 29, // Kohei 393 1065, 8, 2, // Jiryaku 394 1069, 4, 13, // Enkyu 395 1074, 8, 23, // Shoho 396 1077, 11, 17, // Shoryaku 397 1081, 2, 10, // Eiho 398 1084, 2, 7, // Otoku 399 1087, 4, 7, // Kanji 400 1094, 12, 15, // Kaho 401 1096, 12, 17, // Eicho 402 1097, 11, 21, // Shotoku 403 1099, 8, 28, // Kowa 404 1104, 2, 10, // Choji 405 1106, 4, 9, // Kasho 406 1108, 8, 3, // Tennin 407 1110, 7, 13, // Ten-ei 408 1113, 7, 13, // Eikyu 409 1118, 4, 3, // Gen-ei 410 1120, 4, 10, // Hoan 411 1124, 4, 3, // Tenji 412 1126, 1, 22, // Daiji 413 1131, 1, 29, // Tensho 414 1132, 8, 11, // Chosho 415 1135, 4, 27, // Hoen 416 1141, 7, 10, // Eiji 417 1142, 4, 28, // Koji 418 1144, 2, 23, // Tenyo 419 1145, 7, 22, // Kyuan 420 1151, 1, 26, // Ninpei 421 1154, 10, 28, // Kyuju 422 1156, 4, 27, // Hogen 423 1159, 4, 20, // Heiji 424 1160, 1, 10, // Eiryaku 425 1161, 9, 4, // Oho 426 1163, 3, 29, // Chokan 427 1165, 6, 5, // Eiman 428 1166, 8, 27, // Nin-an 429 1169, 4, 8, // Kao 430 1171, 4, 21, // Shoan 431 1175, 7, 28, // Angen 432 1177, 8, 4, // Jisho 433 1181, 7, 14, // Yowa 434 1182, 5, 27, // Juei 435 1184, 4, 16, // Genryuku 436 1185, 8, 14, // Bunji 437 1190, 4, 11, // Kenkyu 438 1199, 4, 27, // Shoji 439 1201, 2, 13, // Kennin 440 1204, 2, 20, // Genkyu 441 1206, 4, 27, // Ken-ei 442 1207, 10, 25, // Shogen 443 1211, 3, 9, // Kenryaku 444 1213, 12, 6, // Kenpo 445 1219, 4, 12, // Shokyu 446 1222, 4, 13, // Joo 447 1224, 11, 20, // Gennin 448 1225, 4, 20, // Karoku 449 1227, 12, 10, // Antei 450 1229, 3, 5, // Kanki 451 1232, 4, 2, // Joei 452 1233, 4, 15, // Tempuku 453 1234, 11, 5, // Bunryaku 454 1235, 9, 19, // Katei 455 1238, 11, 23, // Ryakunin 456 1239, 2, 7, // En-o 457 1240, 7, 16, // Ninji 458 1243, 2, 26, // Kangen 459 1247, 2, 28, // Hoji 460 1249, 3, 18, // Kencho 461 1256, 10, 5, // Kogen 462 1257, 3, 14, // Shoka 463 1259, 3, 26, // Shogen 464 1260, 4, 13, // Bun-o 465 1261, 2, 20, // Kocho 466 1264, 2, 28, // Bun-ei 467 1275, 4, 25, // Kenji 468 1278, 2, 29, // Koan 469 1288, 4, 28, // Shoo 470 1293, 8, 55, // Einin 471 1299, 4, 25, // Shoan 472 1302, 11, 21, // Kengen 473 1303, 8, 5, // Kagen 474 1306, 12, 14, // Tokuji 475 1308, 10, 9, // Enkei 476 1311, 4, 28, // Ocho 477 1312, 3, 20, // Showa 478 1317, 2, 3, // Bunpo 479 1319, 4, 28, // Geno 480 1321, 2, 23, // Genkyo 481 1324, 12, 9, // Shochu 482 1326, 4, 26, // Kareki 483 1329, 8, 29, // Gentoku 484 1331, 8, 9, // Genko 485 1334, 1, 29, // Kemmu 486 1336, 2, 29, // Engen 487 1340, 4, 28, // Kokoku 488 1346, 12, 8, // Shohei 489 1370, 7, 24, // Kentoku 490 1372, 4, 1, // Bunch\u0169 491 1375, 5, 27, // Tenju 492 1379, 3, 22, // Koryaku 493 1381, 2, 10, // Kowa 494 1384, 4, 28, // Gench\u0169 495 1384, 2, 27, // Meitoku 496 1387, 8, 23, // Kakei 497 1389, 2, 9, // Koo 498 1390, 3, 26, // Meitoku 499 1394, 7, 5, // Oei 500 1428, 4, 27, // Shocho 501 1429, 9, 5, // Eikyo 502 1441, 2, 17, // Kakitsu 503 1444, 2, 5, // Bun-an 504 1449, 7, 28, // Hotoku 505 1452, 7, 25, // Kyotoku 506 1455, 7, 25, // Kosho 507 1457, 9, 28, // Choroku 508 1460, 12, 21, // Kansho 509 1466, 2, 28, // Bunsho 510 1467, 3, 3, // Onin 511 1469, 4, 28, // Bunmei 512 1487, 7, 29, // Chokyo 513 1489, 8, 21, // Entoku 514 1492, 7, 19, // Meio 515 1501, 2, 29, // Bunki 516 1504, 2, 30, // Eisho 517 1521, 8, 23, // Taiei 518 1528, 8, 20, // Kyoroku 519 1532, 7, 29, // Tenmon 520 1555, 10, 23, // Koji 521 1558, 2, 28, // Eiroku 522 1570, 4, 23, // Genki 523 1573, 7, 28, // Tensho 524 1592, 12, 8, // Bunroku 525 1596, 10, 27, // Keicho 526 1615, 7, 13, // Genwa 527 1624, 2, 30, // Kan-ei 528 1644, 12, 16, // Shoho 529 1648, 2, 15, // Keian 530 1652, 9, 18, // Shoo 531 1655, 4, 13, // Meiryaku 532 1658, 7, 23, // Manji 533 1661, 4, 25, // Kanbun 534 1673, 9, 21, // Enpo 535 1681, 9, 29, // Tenwa 536 1684, 2, 21, // Jokyo 537 1688, 9, 30, // Genroku 538 1704, 3, 13, // Hoei 539 1711, 4, 25, // Shotoku 540 1716, 6, 22, // Kyoho 541 1736, 4, 28, // Genbun 542 1741, 2, 27, // Kanpo 543 1744, 2, 21, // Enkyo 544 1748, 7, 12, // Kan-en 545 1751, 10, 27, // Horyaku 546 1764, 6, 2, // Meiwa 547 1772, 11, 16, // An-ei 548 1781, 4, 2, // Tenmei 549 1789, 1, 25, // Kansei 550 1801, 2, 5, // Kyowa 551 1804, 2, 11, // Bunka 552 1818, 4, 22, // Bunsei 553 1830, 12, 10, // Tenpo 554 1844, 12, 2, // Koka 555 1848, 2, 28, // Kaei 556 1854, 11, 27, // Ansei 557 1860, 3, 18, // Man-en 558 1861, 2, 19, // Bunkyu 559 1864, 2, 20, // Genji 560 1865, 4, 7, // Keio 561 1868, 9, 8, // Meiji 562 1912, 7, 30, // Taisho 563 1926, 12, 25, // Showa 564 1989, 1, 8, // Heisei 565 }; 566 567 //------------------------------------------------------------------------- 568 // Public constants for some of the recent eras that folks might use... 569 //------------------------------------------------------------------------- 570 571 // Constant for the current era. This must be regularly updated. 572 /** 573 * @stable ICU 2.8 574 */ 575 static public final int CURRENT_ERA = (ERAS.length / 3) - 1; 576 577 /** 578 * Constant for the era starting on Sept. 8, 1868 AD. 579 * @stable ICU 2.8 580 */ 581 static public final int MEIJI = CURRENT_ERA - 3; 582 583 /** 584 * Constant for the era starting on July 30, 1912 AD. 585 * @stable ICU 2.8 586 */ 587 static public final int TAISHO = CURRENT_ERA - 2; 588 589 /** 590 * Constant for the era starting on Dec. 25, 1926 AD. 591 * @stable ICU 2.8 592 */ 593 static public final int SHOWA = CURRENT_ERA - 1; 594 595 /** 596 * Constant for the era starting on Jan. 7, 1989 AD. 597 * @stable ICU 2.8 598 */ 599 static public final int HEISEI = CURRENT_ERA; 600 601 /** 602 * Override GregorianCalendar. We should really handle YEAR_WOY and 603 * EXTENDED_YEAR here too to implement the 1..5000000 range, but it's 604 * not critical. 605 * @stable ICU 2.8 606 */ 607 @SuppressWarnings("fallthrough") 608 protected int handleGetLimit(int field, int limitType) { 609 switch (field) { 610 case ERA: 611 if (limitType == MINIMUM || limitType == GREATEST_MINIMUM) { 612 return 0; 613 } 614 return CURRENT_ERA; 615 case YEAR: 616 { 617 switch (limitType) { 618 case MINIMUM: 619 case GREATEST_MINIMUM: 620 return 1; 621 case LEAST_MAXIMUM: 622 return 1; 623 case MAXIMUM: 624 return super.handleGetLimit(field, MAXIMUM) - ERAS[CURRENT_ERA*3]; 625 } 626 //Fall through to the default if not handled above 627 } 628 default: 629 return super.handleGetLimit(field, limitType); 630 } 631 } 632 633 /** 634 * {@inheritDoc} 635 * @stable ICU 3.8 636 */ 637 public String getType() { 638 return "japanese"; 639 } 640 641 /** 642 * {@inheritDoc} 643 * @internal 644 * @deprecated This API is ICU internal only. 645 */ 646 @Deprecated 647 public boolean haveDefaultCentury() { 648 return false; 649 } 650 651 /** 652 * {@inheritDoc} 653 * @stable ICU 4.0 654 */ 655 public int getActualMaximum(int field) { 656 if (field == YEAR) { 657 int era = get(Calendar.ERA); 658 if (era == CURRENT_ERA) { 659 // TODO: Investigate what value should be used here - revisit after 4.0. 660 return handleGetLimit(YEAR, MAXIMUM); 661 } else { 662 int nextEraYear = ERAS[(era+1)*3]; 663 int nextEraMonth = ERAS[(era+1)*3 + 1]; 664 int nextEraDate = ERAS[(era+1)*3 + 2]; 665 666 int maxYear = nextEraYear - ERAS[era*3] + 1; // 1-base 667 if (nextEraMonth == 1 && nextEraDate == 1) { 668 // Substract 1, because the next era starts at Jan 1 669 maxYear--; 670 } 671 return maxYear; 672 } 673 } 674 return super.getActualMaximum(field); 675 } 676 677} 678