KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > xs > datatypes > XSDateTime


1 /*
2  * Copyright 2004,2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.xerces.xs.datatypes;
17
18 import javax.xml.datatype.Duration JavaDoc;
19 import javax.xml.datatype.XMLGregorianCalendar JavaDoc;
20
21 /**
22  * <p>Interface to expose the values for all date-time related types. The following
23  * table shows the methods defined for various XML Schema 1.0 built-in types. 'X'
24  * marks whether a particular method is defined for a particular type. Accessing undefined
25  * methods may return unexpected values.
26  *
27  * <table border="1">
28  * <br/>
29  * <tr>
30  * <td> XML Schema Datatype </td>
31  * <td> getYears() </td>
32  * <td> getMonths() </td>
33  * <td> getDays() </td>
34  * <td> getHours() </td>
35  * <td> getMinutes() </td>
36  * <td> getSeconds() </td>
37  * <td> getTimeZoneHours() </td>
38  * <td> getTimeZoneMinutes() </td>
39  * <td> getXMLGregorianCalendar() </td>
40  * <td> getDuration() </td>
41  * <td> hasTimeZone() </td>
42  * <td> normalize() </td>
43  * <td> isNormalized() </td>
44  * <td> getLexicalValue() </td>
45  * </tr>
46  * <tr>
47  * <td> gYear </td>
48  * <td>X</td>
49  * <td>-</td>
50  * <td>-</td>
51  * <td>-</td>
52  * <td>-</td>
53  * <td>-</td>
54  * <td>X</td>
55  * <td>X</td>
56  * <td>X</td>
57  * <td>-</td>
58  * <td>X</td>
59  * <td>X</td>
60  * <td>X</td>
61  * <td>X</td>
62  * </tr>
63  * <tr>
64  * <td> gMonth </td>
65  * <td>-</td>
66  * <td>X</td>
67  * <td>-</td>
68  * <td>-</td>
69  * <td>-</td>
70  * <td>-</td>
71  * <td>X</td>
72  * <td>X</td>
73  * <td>X</td>
74  * <td>-</td>
75  * <td>X</td>
76  * <td>X</td>
77  * <td>X</td>
78  * <td>X</td>
79  * </tr>
80  * <tr>
81  * <td> gDay </td>
82  * <td>-</td>
83  * <td>-</td>
84  * <td>X</td>
85  * <td>-</td>
86  * <td>-</td>
87  * <td>-</td>
88  * <td>X</td>
89  * <td>X</td>
90  * <td>X</td>
91  * <td>-</td>
92  * <td>X</td>
93  * <td>X</td>
94  * <td>X</td>
95  * <td>X</td>
96  * </tr>
97  * <tr>
98  * <td> gYearMonth </td>
99  * <td>X</td>
100  * <td>X</td>
101  * <td>-</td>
102  * <td>-</td>
103  * <td>-</td>
104  * <td>-</td>
105  * <td>X</td>
106  * <td>X</td>
107  * <td>X</td>
108  * <td>-</td>
109  * <td>X</td>
110  * <td>X</td>
111  * <td>X</td>
112  * <td>X</td>
113  * </tr>
114  * <tr>
115  * <td> gMonthDay </td>
116  * <td>-</td>
117  * <td>X</td>
118  * <td>X</td>
119  * <td>-</td>
120  * <td>-</td>
121  * <td>-</td>
122  * <td>X</td>
123  * <td>X</td>
124  * <td>X</td>
125  * <td>-</td>
126  * <td>X</td>
127  * <td>X</td>
128  * <td>X</td>
129  * <td>X</td>
130  * </tr>
131  * <tr>
132  * <td> date </td>
133  * <td>X</td>
134  * <td>X</td>
135  * <td>X</td>
136  * <td>-</td>
137  * <td>-</td>
138  * <td>-</td>
139  * <td>X</td>
140  * <td>X</td>
141  * <td>X</td>
142  * <td>-</td>
143  * <td>X</td>
144  * <td>X</td>
145  * <td>X</td>
146  * <td>X</td>
147  * </tr>
148  * <tr>
149  * <td> time </td>
150  * <td>-</td>
151  * <td>-</td>
152  * <td>-</td>
153  * <td>X</td>
154  * <td>X</td>
155  * <td>X</td>
156  * <td>X</td>
157  * <td>X</td>
158  * <td>X</td>
159  * <td>-</td>
160  * <td>X</td>
161  * <td>X</td>
162  * <td>X</td>
163  * <td>X</td>
164  * </tr>
165  * <tr>
166  * <td> datetime </td>
167  * <td>X</td>
168  * <td>X</td>
169  * <td>X</td>
170  * <td>X</td>
171  * <td>X</td>
172  * <td>X</td>
173  * <td>X</td>
174  * <td>X</td>
175  * <td>X</td>
176  * <td>-</td>
177  * <td>X</td>
178  * <td>X</td>
179  * <td>X</td>
180  * <td>X</td>
181  * </tr>
182  * <tr>
183  * <td> duration </td>
184  * <td>-</td>
185  * <td>X</td>
186  * <td>-</td>
187  * <td>-</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  * </tr>
199  * </table>
200  * </p>
201  *
202  * @author Ankit Pasricha, IBM
203  *
204  * @version $Id: XSDateTime.java,v 1.12 2005/05/15 20:37:23 mrglavas Exp $
205  */

206 public interface XSDateTime {
207     
208     /**
209      * @return years - can be negative for date-time related types;
210      *
211      */

212     public int getYears();
213     
214     /**
215      * @return months - can be negative only for duration types;
216      * For duration types, it returns years*12 + months
217      */

218     public int getMonths();
219     
220     /**
221      * @return days - cannot be negative;
222      *
223      */

224     public int getDays();
225     
226     /**
227      * @return hours - cannot be negative;
228      *
229      */

230     public int getHours();
231     
232     /**
233      * @return minutes - cannot be negative;
234      *
235      */

236     public int getMinutes();
237     
238     /**
239      * @return seconds - can be negative only for durations;
240      * For duration types, it returns days*24*3600 + hours*3600
241      * + minutes*60 + seconds
242      */

243     public double getSeconds();
244     
245     /**
246      * @return boolean (true when timezone is specified in the original lexical value)
247      *
248      */

249     public boolean hasTimeZone();
250     
251     /**
252      * @return timezone hours (for GMT-xx:xx this will be negative),
253      *
254      */

255     public int getTimeZoneHours();
256     
257     /**
258      * @return timezone minutes (for GMT-xx:xx this will be negative),
259      *
260      */

261     public int getTimeZoneMinutes();
262     
263     /**
264      * @return the original lexical value
265      */

266     public String JavaDoc getLexicalValue();
267     
268     /**
269      * @return a new date-time related object with normalized values
270      * (has no effect on objects already
271      * normalized)
272      */

273     public XSDateTime normalize();
274     
275     /**
276      * @return whether a date-time related object is normalized or not
277      * (value is not useful for types where timezone is not specified)
278      */

279     public boolean isNormalized();
280        
281     /**
282      * @return an un-normalized XMLGregorianCalendar (if applicable otherwise null)
283      */

284     public XMLGregorianCalendar JavaDoc getXMLGregorianCalendar();
285         
286     /**
287      * @return a Duration (if applicable otherwise null)
288      */

289     public Duration JavaDoc getDuration();
290 }
291
Popular Tags