Source Code Cross Referenced for BuddhistCalendar.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:
008:        package com.ibm.icu.util;
009:
010:        import com.ibm.icu.util.TimeZone;
011:        import java.util.Date;
012:        import java.util.Locale;
013:
014:        /**
015:         * <code>BuddhistCalendar</code> is a subclass of <code>GregorianCalendar</code>
016:         * that numbers years since the birth of the Buddha.  This is the civil calendar
017:         * in some predominantly Buddhist countries such as Thailand, and it is used for
018:         * religious purposes elsewhere.
019:         * <p>
020:         * The Buddhist calendar is identical to the Gregorian calendar in all respects
021:         * except for the year and era.  Years are numbered since the birth of the
022:         * Buddha in 543 BC (Gregorian), so that 1 AD (Gregorian) is equivalent to 544
023:         * BE (Buddhist Era) and 1998 AD is 2541 BE.
024:         * <p>
025:         * The Buddhist Calendar has only one allowable era: <code>BE</code>.  If the
026:         * calendar is not in lenient mode (see <code>setLenient</code>), dates before
027:         * 1/1/1 BE are rejected with an <code>IllegalArgumentException</code>.
028:         * <p>
029:         * This class should not be subclassed.</p>
030:         * <p>
031:         * BuddhistCalendar usually should be instantiated using 
032:         * {@link com.ibm.icu.util.Calendar#getInstance(ULocale)} passing in a <code>ULocale</code>
033:         * with the tag <code>"@calendar=buddhist"</code>.</p>
034:         * 
035:         * @see com.ibm.icu.util.Calendar
036:         * @see com.ibm.icu.util.GregorianCalendar
037:         *
038:         * @author Laura Werner
039:         * @author Alan Liu
040:         * @stable ICU 2.8
041:         */
042:        public class BuddhistCalendar extends GregorianCalendar {
043:            // jdk1.4.2 serialver
044:            private static final long serialVersionUID = 2583005278132380631L;
045:            private static String copyright = "Copyright \u00a9 1998 IBM Corp. All Rights Reserved.";
046:
047:            //-------------------------------------------------------------------------
048:            // Constructors...
049:            //-------------------------------------------------------------------------
050:
051:            /**
052:             * Constant for the Buddhist Era.  This is the only allowable <code>ERA</code>
053:             * value for the Buddhist calendar.
054:             *
055:             * @see com.ibm.icu.util.Calendar#ERA
056:             * @stable ICU 2.8
057:             */
058:            public static final int BE = 0;
059:
060:            /**
061:             * Constructs a <code>BuddhistCalendar</code> using the current time
062:             * in the default time zone with the default locale.
063:             * @stable ICU 2.8
064:             */
065:            public BuddhistCalendar() {
066:                super ();
067:            }
068:
069:            /**
070:             * Constructs a <code>BuddhistCalendar</code> based on the current time
071:             * in the given time zone with the default locale.
072:             *
073:             * @param zone the given time zone.
074:             * @stable ICU 2.8
075:             */
076:            public BuddhistCalendar(TimeZone zone) {
077:                super (zone);
078:            }
079:
080:            /**
081:             * Constructs a <code>BuddhistCalendar</code> based on the current time
082:             * in the default time zone with the given locale.
083:             *
084:             * @param aLocale the given locale.
085:             * @stable ICU 2.8
086:             */
087:            public BuddhistCalendar(Locale aLocale) {
088:                super (aLocale);
089:            }
090:
091:            /**
092:             * Constructs a <code>BuddhistCalendar</code> based on the current time
093:             * in the default time zone with the given locale.
094:             *
095:             * @param locale the given ulocale.
096:             * @draft ICU 3.2
097:             * @provisional This API might change or be removed in a future release.
098:             */
099:            public BuddhistCalendar(ULocale locale) {
100:                super (locale);
101:            }
102:
103:            /**
104:             * Constructs a <code>BuddhistCalendar</code> based on the current time
105:             * in the given time zone with the given locale.
106:             *
107:             * @param zone the given time zone.
108:             *
109:             * @param aLocale the given locale.
110:             * @stable ICU 2.8
111:             */
112:            public BuddhistCalendar(TimeZone zone, Locale aLocale) {
113:                super (zone, aLocale);
114:            }
115:
116:            /**
117:             * Constructs a <code>BuddhistCalendar</code> based on the current time
118:             * in the given time zone with the given locale.
119:             *
120:             * @param zone the given time zone.
121:             *
122:             * @param locale the given ulocale.
123:             * @draft ICU 3.2
124:             * @provisional This API might change or be removed in a future release.
125:             */
126:            public BuddhistCalendar(TimeZone zone, ULocale locale) {
127:                super (zone, locale);
128:            }
129:
130:            /**
131:             * Constructs a <code>BuddhistCalendar</code> with the given date set
132:             * in the default time zone with the default locale.
133:             *
134:             * @param date      The date to which the new calendar is set.
135:             * @stable ICU 2.8
136:             */
137:            public BuddhistCalendar(Date date) {
138:                this ();
139:                setTime(date);
140:            }
141:
142:            /**
143:             * Constructs a <code>BuddhistCalendar</code> with the given date set
144:             * in the default time zone with the default locale.
145:             *
146:             * @param year      The value used to set the calendar's {@link #YEAR YEAR} time field.
147:             *
148:             * @param month     The value used to set the calendar's {@link #MONTH MONTH} time field.
149:             *                  The value is 0-based. e.g., 0 for January.
150:             *
151:             * @param date      The value used to set the calendar's {@link #DATE DATE} time field.
152:             * @stable ICU 2.8
153:             */
154:            public BuddhistCalendar(int year, int month, int date) {
155:                super (year, month, date);
156:            }
157:
158:            /**
159:             * Constructs a BuddhistCalendar with the given date
160:             * and time set for the default time zone with the default locale.
161:             *
162:             * @param year      The value used to set the calendar's {@link #YEAR YEAR} time field.
163:             *
164:             * @param month     The value used to set the calendar's {@link #MONTH MONTH} time field.
165:             *                  The value is 0-based. e.g., 0 for January.
166:             *
167:             * @param date      The value used to set the calendar's {@link #DATE DATE} time field.
168:             *
169:             * @param hour      The value used to set the calendar's {@link #HOUR_OF_DAY HOUR_OF_DAY} time field.
170:             *
171:             * @param minute    The value used to set the calendar's {@link #MINUTE MINUTE} time field.
172:             *
173:             * @param second    The value used to set the calendar's {@link #SECOND SECOND} time field.
174:             * @stable ICU 2.8
175:             */
176:            public BuddhistCalendar(int year, int month, int date, int hour,
177:                    int minute, int second) {
178:                super (year, month, date, hour, minute, second);
179:            }
180:
181:            //-------------------------------------------------------------------------
182:            // The only practical difference from a Gregorian calendar is that years
183:            // are numbered since the birth of the Buddha.  A couple of overrides will
184:            // take care of that....
185:            //-------------------------------------------------------------------------
186:
187:            // Starts in -543 AD, ie 544 BC
188:            private static final int BUDDHIST_ERA_START = -543;
189:
190:            /**
191:             * @stable ICU 2.8
192:             */
193:            protected int handleGetExtendedYear() {
194:                int year;
195:                if (newerField(EXTENDED_YEAR, YEAR) == EXTENDED_YEAR) {
196:                    year = internalGet(EXTENDED_YEAR, 1);
197:                } else {
198:                    // Ignore the era, as there is only one
199:                    year = internalGet(YEAR, 1);
200:                }
201:                return year;
202:            }
203:
204:            // Return JD of start of given month/year
205:            /**
206:             * @stable ICU 2.8
207:             */
208:            protected int handleComputeMonthStart(int eyear, int month,
209:                    boolean useMonth) {
210:                return super .handleComputeMonthStart(
211:                        eyear + BUDDHIST_ERA_START, month, useMonth);
212:            }
213:
214:            /**
215:             * @stable ICU 2.8
216:             */
217:            protected void handleComputeFields(int julianDay) {
218:                super .handleComputeFields(julianDay);
219:                int y = internalGet(EXTENDED_YEAR) - BUDDHIST_ERA_START;
220:                internalSet(EXTENDED_YEAR, y);
221:                internalSet(ERA, 0);
222:                internalSet(YEAR, y);
223:            }
224:
225:            /**
226:             * Override GregorianCalendar.  There is only one Buddhist ERA.  We
227:             * should really handle YEAR, YEAR_WOY, and EXTENDED_YEAR here too to
228:             * implement the 1..5000000 range, but it's not critical.
229:             * @stable ICU 2.8
230:             */
231:            protected int handleGetLimit(int field, int limitType) {
232:                if (field == ERA) {
233:                    return BE;
234:                }
235:                return super .handleGetLimit(field, limitType);
236:            }
237:
238:            /**
239:             * Return the current Calendar type.
240:             * @return type of calendar (gregorian, etc.)
241:             * @internal ICU 3.0
242:             * @deprecated This API is ICU internal only.
243:             */
244:            public String getType() {
245:                return "buddhist";
246:            }
247:
248:            /*
249:            private static CalendarFactory factory;
250:            public static CalendarFactory factory() {
251:                if (factory == null) {
252:                    factory = new CalendarFactory() {
253:                        public Calendar create(TimeZone tz, ULocale loc) {
254:                            return new BuddhistCalendar(tz, loc);
255:                        }
256:
257:                        public String factoryName() {
258:                            return "Buddhist";
259:                        }
260:                    };
261:                }
262:                return factory;
263:            }
264:             */
265:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.