Source Code Cross Referenced for JapaneseCalendar.java in  » Internationalization-Localization » icu4j » com » ibm » icu » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Internationalization Localization » icu4j » com.ibm.icu.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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