Source Code Cross Referenced for Time.java in  » Apache-Harmony-Java-SE » java-package » java » sql » 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 » Apache Harmony Java SE » java package » java.sql 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        package java.sql;
019:
020:        import java.text.SimpleDateFormat;
021:        import java.util.Date;
022:
023:        /**
024:         * Java representation of an SQL TIME value. Provides functions to aid
025:         * generation and interpretation of JDBC escape format for time values.
026:         * 
027:         */
028:        public class Time extends Date {
029:
030:            private static final long serialVersionUID = 8397324403548013681L;
031:
032:            /**
033:             * @deprecated Please use the constructor Time( long ) Constructs a Time
034:             *             object using the supplied values for Hour, Minute and Second.
035:             *             The Year, Month and Day elements of the Time object are set
036:             *             to 1970, January, 1 reflecting the Epoch (Time in
037:             *             milliseconds = 0).
038:             *             <p>
039:             *             Any attempt to access the Year, Month or Day elements of a
040:             *             Time object will result in an IllegalArgumentException.
041:             *             <p>
042:             *             Result is undefined if any argument is out of bounds.
043:             * @param theHour
044:             *            a value from 0 - 23
045:             * @param theMinute
046:             *            a value from 0 - 59
047:             * @param theSecond
048:             *            a value from 0 - 59
049:             */
050:            @SuppressWarnings("deprecation")
051:            @Deprecated
052:            public Time(int theHour, int theMinute, int theSecond) {
053:                super (70, 0, 1, theHour, theMinute, theSecond);
054:            }
055:
056:            /**
057:             * Constructs a Time object using a supplied time specified in milliseconds
058:             * 
059:             * @param theTime
060:             *            a Time specified in milliseconds since the Epoch (January 1st
061:             *            1970, 00:00:00.000)
062:             */
063:            public Time(long theTime) {
064:                super (theTime);
065:            }
066:
067:            /**
068:             * @deprecated This method is deprecated and must not be used. An SQL Time
069:             *             object does not have a Date component.
070:             * @return does not return
071:             * @throws IllegalArgumentException
072:             *             if this method is called
073:             */
074:            @SuppressWarnings("deprecation")
075:            @Deprecated
076:            @Override
077:            public int getDate() {
078:                throw new IllegalArgumentException();
079:            }
080:
081:            /**
082:             * @deprecated This method is deprecated and must not be used. An SQL Time
083:             *             object does not have a Day component.
084:             * @return does not return
085:             * @throws IllegalArgumentException
086:             *             if this method is called
087:             */
088:            @SuppressWarnings("deprecation")
089:            @Deprecated
090:            @Override
091:            public int getDay() {
092:                throw new IllegalArgumentException();
093:            }
094:
095:            /**
096:             * @deprecated This method is deprecated and must not be used. An SQL Time
097:             *             object does not have a Month component.
098:             * @return does not return
099:             * @throws IllegalArgumentException
100:             *             if this method is called
101:             */
102:            @SuppressWarnings("deprecation")
103:            @Deprecated
104:            @Override
105:            public int getMonth() {
106:                throw new IllegalArgumentException();
107:            }
108:
109:            /**
110:             * @deprecated This method is deprecated and must not be used. An SQL Time
111:             *             object does not have a Year component.
112:             * @return does not return
113:             * @throws IllegalArgumentException
114:             *             if this method is called
115:             */
116:            @SuppressWarnings("deprecation")
117:            @Deprecated
118:            @Override
119:            public int getYear() {
120:                throw new IllegalArgumentException();
121:            }
122:
123:            /**
124:             * @deprecated This method is deprecated and must not be used. An SQL Time
125:             *             object does not have a Date component.
126:             * @throws IllegalArgumentException
127:             *             if this method is called
128:             */
129:            @SuppressWarnings("deprecation")
130:            @Deprecated
131:            @Override
132:            public void setDate(int i) {
133:                throw new IllegalArgumentException();
134:            }
135:
136:            /**
137:             * @deprecated This method is deprecated and must not be used. An SQL Time
138:             *             object does not have a Month component.
139:             * @throws IllegalArgumentException
140:             *             if this method is called
141:             */
142:            @SuppressWarnings("deprecation")
143:            @Deprecated
144:            @Override
145:            public void setMonth(int i) {
146:                throw new IllegalArgumentException();
147:            }
148:
149:            /**
150:             * @deprecated This method is deprecated and must not be used. An SQL Time
151:             *             object does not have a Year component.
152:             * @throws IllegalArgumentException
153:             *             if this method is called
154:             */
155:            @SuppressWarnings("deprecation")
156:            @Deprecated
157:            @Override
158:            public void setYear(int i) {
159:                throw new IllegalArgumentException();
160:            }
161:
162:            /**
163:             * Sets the time for this Time object to the supplied milliseconds value.
164:             * 
165:             * @param time
166:             *            A time value expressed as milliseconds since the Epoch.
167:             *            Negative values are milliseconds before the Epoch. The Epoch
168:             *            is January 1 1970, 00:00:00.000
169:             */
170:            @Override
171:            public void setTime(long time) {
172:                super .setTime(time);
173:            }
174:
175:            /**
176:             * Formats the Time as a String in JDBC escape format: hh:mm:ss
177:             * 
178:             * @return A String representing the Time value in JDBC escape format:
179:             *         HH:mm:ss
180:             */
181:            @Override
182:            public String toString() {
183:                SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); //$NON-NLS-1$
184:                return dateFormat.format(this );
185:            }
186:
187:            /**
188:             * Creates a Time object from a String holding a time represented in JDBC
189:             * escape format: hh:mm:ss.
190:             * <p>
191:             * An exception occurs if the input string is not in the form of a time in
192:             * JDBC escape format.
193:             * 
194:             * @param timeString
195:             *            A String representing the time value in JDBC escape format:
196:             *            hh:mm:ss
197:             * @return The Time object set to a time corresponding to the given time
198:             * @throws IllegalArgumentException
199:             *             if the supplied time string is not in JDBC escape format.
200:             */
201:            public static Time valueOf(String timeString) {
202:                if (timeString == null) {
203:                    throw new IllegalArgumentException();
204:                }
205:                int firstIndex = timeString.indexOf(':');
206:                int secondIndex = timeString.indexOf(':', firstIndex + 1);
207:                // secondIndex == -1 means none or only one separator '-' has been
208:                // found.
209:                // The string is separated into three parts by two separator characters,
210:                // if the first or the third part is null string, we should throw
211:                // IllegalArgumentException to follow RI
212:                if (secondIndex == -1 || firstIndex == 0
213:                        || secondIndex + 1 == timeString.length()) {
214:                    throw new IllegalArgumentException();
215:                }
216:                // parse each part of the string
217:                int hour = Integer
218:                        .parseInt(timeString.substring(0, firstIndex));
219:                int minute = Integer.parseInt(timeString.substring(
220:                        firstIndex + 1, secondIndex));
221:                int second = Integer.parseInt(timeString.substring(
222:                        secondIndex + 1, timeString.length()));
223:                return new Time(hour, minute, second);
224:            }
225:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.