001: /*
002: * The Apache Software License, Version 1.1
003: *
004: *
005: * Copyright (c) 1999 The Apache Software Foundation. All rights
006: * reserved.
007: *
008: * Redistribution and use in source and binary forms, with or without
009: * modification, are permitted provided that the following conditions
010: * are met:
011: *
012: * 1. Redistributions of source code must retain the above copyright
013: * notice, this list of conditions and the following disclaimer.
014: *
015: * 2. Redistributions in binary form must reproduce the above copyright
016: * notice, this list of conditions and the following disclaimer in
017: * the documentation and/or other materials provided with the
018: * distribution.
019: *
020: * 3. The end-user documentation included with the redistribution,
021: * if any, must include the following acknowledgment:
022: * "This product includes software developed by the
023: * Apache Software Foundation (http://www.apache.org/)."
024: * Alternately, this acknowledgment may appear in the software itself,
025: * if and wherever such third-party acknowledgments normally appear.
026: *
027: * 4. The names "Xerces" and "Apache Software Foundation" must
028: * not be used to endorse or promote products derived from this
029: * software without prior written permission. For written
030: * permission, please contact apache@apache.org.
031: *
032: * 5. Products derived from this software may not be called "Apache",
033: * nor may "Apache" appear in their name, without prior written
034: * permission of the Apache Software Foundation.
035: *
036: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
037: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
038: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
039: * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
040: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
041: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
042: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
043: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
044: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
045: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
046: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
047: * SUCH DAMAGE.
048: * ====================================================================
049: *
050: * This software consists of voluntary contributions made by many
051: * individuals on behalf of the Apache Software Foundation and was
052: * originally based on software copyright (c) 1999, International
053: * Business Machines, Inc., http://www.apache.org. For more
054: * information on the Apache Software Foundation, please see
055: * <http://www.apache.org/>.
056: */
057:
058: package org.apache.xerces.utils;
059:
060: import java.lang.*;
061:
062: /**
063: * This class provides ISO8601 date/time formatting conversion into
064: * Java DateFormat,
065: * This is based on ISO Internation Standard 1988-06-15
066: *
067:
068:
069: timeDuration
070: ============
071: PnYnMnDTnHnMnS
072:
073: Years
074: Months
075: Days
076:
077: Hours
078: Minutes
079: Seconds
080:
081: x < y iff x-y is positive
082:
083:
084: recurringDuration
085: ================
086: timeDuration that recurrs from a specific origin.
087:
088: 2 constraining facets:
089:
090: duration ( timeDuration)
091: 0 a single instant of time
092:
093: period ( timeDuration)
094: 0 does not recurr
095:
096: both duration and period should be given
097:
098: CCYY-MM-DDThh:mm:ss.sss Z
099:
100: Z Coordinated Universal Time -
101: difference between the local time and Coordinated Universal Time
102: +/-
103:
104:
105: Derived Datatype timeInstant uses same lexical
106: Date, time, timePeriod, recurringDate use truncated version
107:
108: Suppose we wanted to define a day of the week i.e. a 24 hour duration that recurs every 7 days. This could be done as follows:
109: <simpleType name='dayOfWeek' base='recurringDuration'>
110: <duration value='PT24H'/>
111: <period value='P7D'/>
112: </simpleType>
113:
114:
115: timeInstant
116: ===========
117:
118: for Calendar Dates:
119: year - month - day - time designator - hour - minute - second
120:
121: for ordinal date:
122: year - day - time designator - hour - minute - second
123:
124: for dates identified by week and day numbers:
125: year - week designator - week - day - time designator - hour - minute - second
126:
127: T - time designator
128: - and : are separators
129:
130: T maybe omitted ub applications where there is no risk of confusing a combined date and time.
131:
132: CCYYMMDDThhmmss
133: CCYYMMDDThhmm
134: CCYYMMDDThh
135:
136:
137: CCYY-MM-DDThh:mm:ss
138: CCYY-MM-DDThh:mm
139: CCYY-MM-DDThh
140:
141: CCYYDDDThhmmss
142: CCYYDDDThhmm
143: CCYYDDDThh
144:
145: CCYY-DDDThh:mm:ss
146: CCYY-DDDThh:mm
147: CCYY-DDDThh
148:
149: CCYYWwwDThhmmss
150: CCYYWwwDThhmm
151: CCYYWwwDThh
152:
153: CCYY-Www-DThh:mm:ss
154: CCYY-Www-DThh:mm
155: CCYY-Www-DThh
156:
157:
158: TimeInstant has as basetype recurrindDuration where
159: duration facet = P0Y
160: period facet = P0Y
161:
162: 1999-05-31T13:20:00-05:00.
163:
164:
165:
166: time
167: ====
168: base type is recurringDuration
169: duration facet = P0Y
170: period facet = PY24H ; since this instance of time occurs every 24 hours
171:
172: Time are in 24 hour period.
173:
174:
175: Lexical is left truncated representation for timeInstant
176: with optional following time zone indicator.
177:
178: 13:20:00-05:00
179:
180: Basic forms
181: Extended forms
182:
183: Fractions are indicated by [.] or [,].
184: Comma is preferred ( should support both).
185:
186: Coordinated UTC
187: ===============
188:
189: Time representation as above following immediately without spaces
190: by time-zone designator [Z].
191:
192: Local Time
193: ==========
194: Time difference should be expressed only in:
195: hours minutes
196: hours
197: +/-
198: Should not be used alone!
199:
200: timePeriod
201: ==========
202: baseType - recurringDuration with period face equal to "P0Y" (no recurrence
203: Domain is space of Periods of time.
204:
205: So as per ISO spece is either:
206:
207: a - duration of tome delimited by a specific start and specific end
208: b - quantity of time expressed in one or more specific components
209: but not associated with any specific start or end.
210: c - A quantity of time associated with a specific start.
211: d - A quantity of time associated with a specific end.
212:
213: two components can be separated by a solidus [/] for a, b, and c
214:
215: a) basic format:
216: CCYYMMDDThhmmss/CCYYMMDDThhmmss
217:
218: b) representation of duration of time
219: Basic format: PnYnMnDTnHnMnS
220:
221: c) Representation of Period identified by its start and its duration.
222: CCYYMMDDThhmmss/PnYnnMnDTnHnMnS
223:
224: d) Representation of period identified by its duration and its end.
225: PnYnMnDTnHnMnS/CCYYMMDDThhmmss
226:
227: date
228: ====
229:
230: month
231: =====
232:
233: year
234: ====
235:
236: century
237: =======
238:
239: recurringDate
240: =============
241:
242: recurringDay
243: ============
244:
245:
246:
247: TimeInstant
248: ===========
249:
250: Combination od date and time values that represent a single instant in time
251:
252: Space of Gregorian dates and legal times
253: Lexical:
254:
255:
256: CCYY-MM-DDThh:mm:ss.ssss
257:
258: CC Century
259: YY Year
260: MM Month
261: DD day
262: Optional - by default a + is assumed or omitted
263: T date/time separator
264: hh hour
265: mm minute
266: ss.sss second , additional digits may be used
267: Additional digits to left can be added to allow for years greater than 9999
268:
269: CCYY-MM-DDThh:mm:ss.ssss can be followed by a Z to indicate Coordinated Universal
270: Time.
271:
272: To indicate time zone the difference between the local time and Coordinated Universal
273: Time, follows the time and consist of a sign, + or - followed by hh:mm
274:
275: e.g. 1999-05-31T13:20:00-05:00
276:
277: TimeDuration
278: ============
279: P1Y2M3DT10H30M
280:
281: PnYnMnDTnH nMnS
282: nY number of Years
283: nM number of Hours
284: nD number of days
285: T date/time separator
286: nH number of hours
287: nM number of minutes
288: nS number of seconds
289:
290:
291: recurringInstant
292: ===============
293:
294: Lexical
295: =======
296: Left truncated representation for timeInstant
297:
298: -CC omitted from the timeInstant representation it means a timeinstant
299: that recurs every hundred years.
300: -CCYY omitted is designated a time instant that recurrs every year.
301: -Every two character "unit" of the representation that is omitted is indicated
302: by a single hyphen "-".
303: 1:20 pm on May the 31st every year is
304: --05-31T13:20:00-05:00
305:
306:
307: */
308:
309: /**
310: *
311: * @author Jeffrey Rodriguez
312: * @version
313: */
314:
315: public final class ISO8601Format {
316:
317: // DateFormat dateJava = 0;
318:
319: public ISO8601Format(String dateString) {
320:
321: }
322:
323: //public DateFormat
324:
325: /**
326: * Encodes hex octects into Base64
327: *
328: * @param binaryData Array containing binaryData
329: * @return Encoded Base64 array
330: */
331:
332: }
|