Source Code Cross Referenced for TimeZone.java in  » 6.0-JDK-Modules » j2me » java » 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 » 6.0 JDK Modules » j2me » java.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *   
003:         *
004:         * Portions Copyright  2000-2007 Sun Microsystems, Inc. All Rights
005:         * Reserved.  Use is subject to license terms.
006:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
007:         * 
008:         * This program is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public License version
010:         * 2 only, as published by the Free Software Foundation.
011:         * 
012:         * This program is distributed in the hope that it will be useful, but
013:         * WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015:         * General Public License version 2 for more details (a copy is
016:         * included at /legal/license.txt).
017:         * 
018:         * You should have received a copy of the GNU General Public License
019:         * version 2 along with this work; if not, write to the Free Software
020:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
021:         * 02110-1301 USA
022:         * 
023:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
024:         * Clara, CA 95054 or visit www.sun.com if you need additional
025:         * information or have any questions.
026:         */
027:
028:        /*
029:         * (C) Copyright Taligent, Inc. 1996-1998 - All Rights Reserved
030:         * (C) Copyright IBM Corp. 1996-1998 - All Rights Reserved
031:         *
032:         *   The original version of this source code and documentation is copyrighted
033:         * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These
034:         * materials are provided under terms of a License Agreement between Taligent
035:         * and Sun. This technology is protected by multiple US and International
036:         * patents. This notice and attribution to Taligent may not be removed.
037:         *   Taligent is a registered trademark of Taligent, Inc.
038:         *
039:         */
040:
041:        package java.util;
042:
043:        import com.sun.cldc.util.j2me.TimeZoneImpl;
044:
045:        /**
046:         * <code>TimeZone</code> represents a time zone offset, and also figures 
047:         * out daylight savings.
048:         * <p>
049:         * Typically, you get a <code>TimeZone</code> using <code>getDefault</code>
050:         * which creates a <code>TimeZone</code> based on the time zone where the program
051:         * is running. For example, for a program running in Japan, <code>getDefault</code>
052:         * creates a <code>TimeZone</code> object based on Japanese Standard Time.
053:         * <p>
054:         * You can also get a <code>TimeZone</code> using <code>getTimeZone</code> along
055:         * with a time zone ID. For instance, the time zone ID for the Pacific
056:         * Standard Time zone is "PST". So, you can get a PST <code>TimeZone</code> object
057:         * with:
058:         * <blockquote>
059:         * <pre>
060:         * TimeZone tz = TimeZone.getTimeZone("PST");
061:         * </pre>
062:         * </blockquote>
063:         *
064:         * <p> This class is a pure subset of the java.util.TimeZone class in JDK 1.3.
065:         * <p> The only time zone ID that is required to be supported is "GMT".
066:         * <p>
067:         * Apart from the methods and variables being subset, the semantics of the
068:         * getTimeZone() method may also be subset: custom IDs such as "GMT-8:00"
069:         * are not required to be supported.
070:         *
071:         * @see     java.util.Calendar
072:         * @see     java.util.Date
073:         * @version CLDC 1.1 02/01/2002 (Based on JDK 1.3)
074:         */
075:        public abstract class TimeZone {
076:
077:            private static TimeZoneImpl defaultZone = null;
078:            private static String platform = null;
079:
080:            public TimeZone() {
081:            }
082:
083:            /**
084:             * Gets offset, for current date, modified in case of
085:             * daylight savings. This is the offset to add *to* GMT to get local time.
086:             * Gets the time zone offset, for current date, modified in case of daylight
087:             * savings. This is the offset to add *to* GMT to get local time. Assume
088:             * that the start and end month are distinct. This method may return incorrect
089:             * results for rules that start at the end of February (e.g., last Sunday in
090:             * February) or the beginning of March (e.g., March 1).
091:             *
092:             * @param era           The era of the given date (0 = BC, 1 = AD).
093:             * @param year          The year in the given date.
094:             * @param month         The month in the given date. Month is 0-based. e.g.,
095:             *                      0 for January.
096:             * @param day           The day-in-month of the given date.
097:             * @param dayOfWeek     The day-of-week of the given date.
098:             * @param millis        The milliseconds in day in <em>standard</em> local time.
099:             * @return              The offset to add *to* GMT to get local time.
100:             * @exception IllegalArgumentException the era, month, day,
101:             * dayOfWeek, or millis parameters are out of range
102:             */
103:            public abstract int getOffset(int era, int year, int month,
104:                    int day, int dayOfWeek, int millis);
105:
106:            /**
107:             * Gets the GMT offset for this time zone.
108:             *
109:             * @return the GMT offset for this time zone.
110:             */
111:            public abstract int getRawOffset();
112:
113:            /**
114:             * Queries if this time zone uses Daylight Savings Time.
115:             *
116:             * @return if this time zone uses Daylight Savings Time.
117:             */
118:            public abstract boolean useDaylightTime();
119:
120:            /**
121:             * Gets the ID of this time zone.
122:             * @return the ID of this time zone.
123:             */
124:            public String getID() {
125:                return null;
126:            }
127:
128:            /**
129:             * Gets the <code>TimeZone</code> for the given ID.
130:             * @param ID the ID for a <code>TimeZone</code>, either an abbreviation such as
131:             * "GMT", or a full name such as "America/Los_Angeles".
132:             * <p> The only time zone ID that is required to be supported is "GMT".
133:             *
134:             * @return the specified TimeZone, or the GMT zone if the given ID cannot be
135:             * understood.
136:             */
137:            public static synchronized TimeZone getTimeZone(String ID) {
138:                if (ID == null) {
139:                    throw new NullPointerException();
140:                }
141:                getDefault();
142:                TimeZone tz = defaultZone.getInstance(ID);
143:                if (tz == null) {
144:                    tz = defaultZone.getInstance("GMT");
145:                }
146:                return tz;
147:            }
148:
149:            /**
150:             * Gets the default <code>TimeZone</code> for this host.
151:             * The source of the default <code>TimeZone</code>
152:             * may vary with implementation.
153:             * @return a default <code>TimeZone</code>.
154:             */
155:
156:            /* <p>
157:             * The following is information for implementers. Applications
158:             * should not need to be aware of this or rely on it, because 
159:             * each implementation may do it differently:
160:             * <p>
161:             * The TimeZone class will look up a time zone implementation
162:             * class at runtime. The class name will take the form:
163:             * <p>
164:             * <code>{classRoot}.util.{platform}.TimeZoneImpl</code>
165:             * <p>
166:             * To simplify things, we use a hard-coded path name here.
167:             * Actual location of the implementation class may vary 
168:             * from one implementation to another.
169:             */
170:            public static synchronized TimeZone getDefault() {
171:                if (defaultZone == null) {
172:                    try {
173:                        Class clazz = Class
174:                                .forName("com.sun.cldc.util.j2me.TimeZoneImpl");
175:
176:                        // Construct a new TimeZoneImpl instance
177:                        defaultZone = (TimeZoneImpl) clazz.newInstance();
178:                        defaultZone = (TimeZoneImpl) defaultZone
179:                                .getInstance(null);
180:                    } catch (Exception x) {
181:                    }
182:                }
183:                return defaultZone;
184:            }
185:
186:            /** 
187:             * Gets all the available IDs supported.
188:             * @return  an array of IDs.
189:             */
190:            public static String[] getAvailableIDs() {
191:                getDefault();
192:                return defaultZone.getIDs();
193:            }
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.