View Javadoc
1   /*
2    * reserved comment block
3    * DO NOT REMOVE OR ALTER!
4    */
5   /*
6    * Copyright 2004,2005 The Apache Software Foundation.
7    *
8    * Licensed under the Apache License, Version 2.0 (the "License");
9    * you may not use this file except in compliance with the License.
10   * You may obtain a copy of the License at
11   *
12   *      http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  package com.sun.org.apache.xerces.internal.xs.datatypes;
21  
22  import javax.xml.datatype.Duration;
23  import javax.xml.datatype.XMLGregorianCalendar;
24  
25  /**
26   * <p>Interface to expose the values for all date-time related types. The following
27   * table shows the methods defined for various XML Schema 1.0 built-in types. 'X'
28   * marks whether a particular method is defined for a particular type. Accessing undefined
29   * methods may return unexpected values.
30   *
31   * <table border="1">
32   * <br/>
33   * <tr>
34   * <td> XML Schema Datatype </td>
35   * <td> getYears() </td>
36   * <td> getMonths() </td>
37   * <td> getDays() </td>
38   * <td> getHours() </td>
39   * <td> getMinutes() </td>
40   * <td> getSeconds() </td>
41   * <td> getTimeZoneHours() </td>
42   * <td> getTimeZoneMinutes() </td>
43   * <td> getXMLGregorianCalendar() </td>
44   * <td> getDuration() </td>
45   * <td> hasTimeZone() </td>
46   * <td> normalize() </td>
47   * <td> isNormalized() </td>
48   * <td> getLexicalValue() </td>
49   * </tr>
50   * <tr>
51   * <td> gYear </td>
52   * <td>X</td>
53   * <td>-</td>
54   * <td>-</td>
55   * <td>-</td>
56   * <td>-</td>
57   * <td>-</td>
58   * <td>X</td>
59   * <td>X</td>
60   * <td>X</td>
61   * <td>-</td>
62   * <td>X</td>
63   * <td>X</td>
64   * <td>X</td>
65   * <td>X</td>
66   * </tr>
67   * <tr>
68   * <td> gMonth </td>
69   * <td>-</td>
70   * <td>X</td>
71   * <td>-</td>
72   * <td>-</td>
73   * <td>-</td>
74   * <td>-</td>
75   * <td>X</td>
76   * <td>X</td>
77   * <td>X</td>
78   * <td>-</td>
79   * <td>X</td>
80   * <td>X</td>
81   * <td>X</td>
82   * <td>X</td>
83   * </tr>
84   * <tr>
85   * <td> gDay </td>
86   * <td>-</td>
87   * <td>-</td>
88   * <td>X</td>
89   * <td>-</td>
90   * <td>-</td>
91   * <td>-</td>
92   * <td>X</td>
93   * <td>X</td>
94   * <td>X</td>
95   * <td>-</td>
96   * <td>X</td>
97   * <td>X</td>
98   * <td>X</td>
99   * <td>X</td>
100  * </tr>
101  * <tr>
102  * <td> gYearMonth </td>
103  * <td>X</td>
104  * <td>X</td>
105  * <td>-</td>
106  * <td>-</td>
107  * <td>-</td>
108  * <td>-</td>
109  * <td>X</td>
110  * <td>X</td>
111  * <td>X</td>
112  * <td>-</td>
113  * <td>X</td>
114  * <td>X</td>
115  * <td>X</td>
116  * <td>X</td>
117  * </tr>
118  * <tr>
119  * <td> gMonthDay </td>
120  * <td>-</td>
121  * <td>X</td>
122  * <td>X</td>
123  * <td>-</td>
124  * <td>-</td>
125  * <td>-</td>
126  * <td>X</td>
127  * <td>X</td>
128  * <td>X</td>
129  * <td>-</td>
130  * <td>X</td>
131  * <td>X</td>
132  * <td>X</td>
133  * <td>X</td>
134  * </tr>
135  * <tr>
136  * <td> date </td>
137  * <td>X</td>
138  * <td>X</td>
139  * <td>X</td>
140  * <td>-</td>
141  * <td>-</td>
142  * <td>-</td>
143  * <td>X</td>
144  * <td>X</td>
145  * <td>X</td>
146  * <td>-</td>
147  * <td>X</td>
148  * <td>X</td>
149  * <td>X</td>
150  * <td>X</td>
151  * </tr>
152  * <tr>
153  * <td> time </td>
154  * <td>-</td>
155  * <td>-</td>
156  * <td>-</td>
157  * <td>X</td>
158  * <td>X</td>
159  * <td>X</td>
160  * <td>X</td>
161  * <td>X</td>
162  * <td>X</td>
163  * <td>-</td>
164  * <td>X</td>
165  * <td>X</td>
166  * <td>X</td>
167  * <td>X</td>
168  * </tr>
169  * <tr>
170  * <td> datetime </td>
171  * <td>X</td>
172  * <td>X</td>
173  * <td>X</td>
174  * <td>X</td>
175  * <td>X</td>
176  * <td>X</td>
177  * <td>X</td>
178  * <td>X</td>
179  * <td>X</td>
180  * <td>-</td>
181  * <td>X</td>
182  * <td>X</td>
183  * <td>X</td>
184  * <td>X</td>
185  * </tr>
186  * <tr>
187  * <td> duration </td>
188  * <td>-</td>
189  * <td>X</td>
190  * <td>-</td>
191  * <td>-</td>
192  * <td>-</td>
193  * <td>X</td>
194  * <td>-</td>
195  * <td>-</td>
196  * <td>-</td>
197  * <td>X</td>
198  * <td>-</td>
199  * <td>-</td>
200  * <td>-</td>
201  * <td>X</td>
202  * </tr>
203  * </table>
204  * </p>
205  *
206  * @author Ankit Pasricha, IBM
207  *
208  */
209 public interface XSDateTime {
210 
211     /**
212      * @return years - can be negative for date-time related types;
213      *
214      */
215     public int getYears();
216 
217     /**
218      * @return months - can be negative only for duration types;
219      *                  For duration types, it returns years*12 + months
220      */
221     public int getMonths();
222 
223     /**
224      * @return days - cannot be negative;
225      *
226      */
227     public int getDays();
228 
229     /**
230      * @return hours - cannot be negative;
231      *
232      */
233     public int getHours();
234 
235     /**
236      * @return minutes - cannot be negative;
237      *
238      */
239     public int getMinutes();
240 
241     /**
242      * @return seconds - can be negative only for durations;
243      *                   For duration types, it returns days*24*3600 + hours*3600
244      *                                                  + minutes*60 + seconds
245      */
246     public double getSeconds();
247 
248     /**
249      * @return boolean (true when timezone is specified in the original lexical value)
250      *
251      */
252     public boolean hasTimeZone();
253 
254     /**
255      * @return timezone hours (for GMT-xx:xx this will be negative),
256      *
257      */
258     public int getTimeZoneHours();
259 
260     /**
261      * @return timezone minutes (for GMT-xx:xx this will be negative),
262      *
263      */
264     public int getTimeZoneMinutes();
265 
266     /**
267      * @return the original lexical value
268      */
269     public String getLexicalValue();
270 
271     /**
272      * @return a new date-time related object with normalized values
273      *         (has no effect on objects already
274      *          normalized)
275      */
276     public XSDateTime normalize();
277 
278     /**
279      * @return whether a date-time related object is normalized or not
280      *         (value is not useful for types where timezone is not specified)
281      */
282     public boolean isNormalized();
283 
284     /**
285      * @return an un-normalized XMLGregorianCalendar (if applicable otherwise null)
286      */
287     public XMLGregorianCalendar getXMLGregorianCalendar();
288 
289     /**
290      * @return a Duration (if applicable otherwise null)
291      */
292     public Duration getDuration();
293 }