commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton (JIRA)" <>
Subject [jira] Updated: (LANG-362) Add ExtendedMessageFormat to org.apache.commons.lang.text
Date Thu, 31 Jan 2008 04:39:34 GMT


Niall Pemberton updated LANG-362:


OK I'm attaching the following implementations

 - ExtendedMessageFormat2
 - FormatFactory
 - DateFormatFactory

The DateFormatFactory is an example FormatFactory implementation that supports the existing
"date" and "time" format types, but also adds a new "datetime" type. (btw its written as it
is so that it can be used to implement Lang's FastDateFormat implementation - by just overriding
the protected methods).

So to use the new "datetime" type, all thats required is the following:

        Map registry = new HashMap();
        registry.put("datetime", new DateFormatFactory());

        String pattern = "Date: {0,date,short} Time: {0,time,medium} Date/Time: {0,datetime,long}";
        ExtendedMessageFormat2 fmt = new ExtendedMessageFormat2(pattern, registry);

        System.out.println(fmt.format(new Object[] {new Date()}));

Note that the "date" and "time" types are not being handled by our custom factory - the standard
MessageFormat functionality is doing that. If we wanted we could register custom formats for
those standard types as well.

Maybe I'm missing something, but is this not achieving the same goal?

> Add ExtendedMessageFormat to org.apache.commons.lang.text
> ---------------------------------------------------------
>                 Key: LANG-362
>                 URL:
>             Project: Commons Lang
>          Issue Type: New Feature
>            Reporter: Matt Benson
>            Assignee: Matt Benson
>            Priority: Minor
>             Fix For: 2.4
>         Attachments:, extendedMessageFormat.patch.txt, extendedMessageFormat.patch.txt,,
> Discussed on dev@ (
); adding here for tracking purposes and in case anyone has any serious objections to my implementation.
 Patch forthcoming...

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message