Henri Yandell wrote on Monday, March 06, 2006 9:02 AM:

> This seems like a useful class to me. Any reason not to add it?
> 
> http://issues.apache.org/bugzilla/show_bug.cgi?id=38772

It's way from complete. While some ISO8601formats are quite obscure, using UTC  
is really common, otherwise you're dependend on a time zone. With JDK 1.4 you 
can mimik this using the 'Z' formatting symbol ... but that does not exist in 
JDK 1.3 (but in lang.FastDateFormat). Personally I have extended 
SimpleDateFormat to handle a lot of the ISO8601 (and to be able to use the 
symbols of ISO 8601 to define a format):

    public void testAllStandardFormatter() {
        final Calendar calendar = Calendar.getInstance();
        calendar.setTimeZone(TimeZone.getTimeZone("Europe/Berlin"));
        calendar.setTimeInMillis(50);
        calendar.set(1968, Calendar.MAY, 28, 13, 30, 10);
        final Date date = calendar.getTime();
        assertEquals("680528", ISO8601DateFormat.BASIC_DATE.format(date));
        assertEquals("1968-05-28", 
ISO8601DateFormat.EXTENDED_DATE.format(date));
        assertEquals("133010", ISO8601DateFormat.BASIC_TIME.format(date));
        assertEquals("13:30:10", ISO8601DateFormat.EXTENDED_TIME.format(date));
        assertEquals("133010,050", 
ISO8601DateFormat.BASIC_TIME_FRACTION.format(date));
        assertEquals("13:30:10,050", 
ISO8601DateFormat.EXTENDED_TIME_FRACTION.format(date));
        assertEquals("123010Z", ISO8601DateFormat.BASIC_TIME_UTC.format(date));
        assertEquals("12:30:10Z", 
ISO8601DateFormat.EXTENDED_TIME_UTC.format(date));
        assertEquals("123010,050Z", 
ISO8601DateFormat.BASIC_TIME_UTC_FRACTION.format(date));
        assertEquals("12:30:10,050Z", 
ISO8601DateFormat.EXTENDED_TIME_UTC_FRACTION.format(date));
        assertEquals("123010+0000", 
ISO8601DateFormat.BASIC_TIME_OFFSET.format(date));
        assertEquals("12:30:10+0000", 
ISO8601DateFormat.EXTENDED_TIME_OFFSET.format(date));
        assertEquals("680528T133010", 
ISO8601DateFormat.BASIC_DATE_TIME.format(date));
        assertEquals("1968-05-28T13:30:10", 
ISO8601DateFormat.EXTENDED_DATE_TIME.format(date));
        assertEquals("680528T133010,050", 
ISO8601DateFormat.BASIC_DATE_TIME_FRACTION.format(date));
        assertEquals("1968-05-28T13:30:10,050", 
ISO8601DateFormat.EXTENDED_DATE_TIME_FRACTION.format(date));
        assertEquals("680528T123010Z", 
ISO8601DateFormat.BASIC_DATE_TIME_UTC.format(date));
        assertEquals("1968-05-28T12:30:10Z", 
ISO8601DateFormat.EXTENDED_DATE_TIME_UTC.format(date));
        assertEquals("680528T123010,050Z", 
ISO8601DateFormat.BASIC_DATE_TIME_UTC_FRACTION.format(date));
        assertEquals("1968-05-28T12:30:10,050Z", 
ISO8601DateFormat.EXTENDED_DATE_TIME_UTC_FRACTION.format(date));
        assertEquals("680528T123010+0000", 
ISO8601DateFormat.BASIC_DATE_TIME_OFFSET.format(date));
        assertEquals("1968-05-28T12:30:10+0000", 
ISO8601DateFormat.EXTENDED_DATE_TIME_OFFSET.format(date));
    }


That would be an IMHO an interesting extension to lang (since FastDateFormat 
provides the necessary functionality and DateRangeUtils already deal with 
ISO8601 symbols). WDYT?

- Jörg

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to