You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Niall Pemberton (JIRA)" <ji...@apache.org> on 2008/01/31 05:39:34 UTC

[jira] Updated: (LANG-362) Add ExtendedMessageFormat to org.apache.commons.lang.text

     [ https://issues.apache.org/jira/browse/LANG-362?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Niall Pemberton updated LANG-362:
---------------------------------

    Attachment: DateFormatFactory.java
                FormatFactory.java
                ExtendedMessageFormat2.java

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: https://issues.apache.org/jira/browse/LANG-362
>             Project: Commons Lang
>          Issue Type: New Feature
>            Reporter: Matt Benson
>            Assignee: Matt Benson
>            Priority: Minor
>             Fix For: 2.4
>
>         Attachments: DateFormatFactory.java, extendedMessageFormat.patch.txt, extendedMessageFormat.patch.txt, ExtendedMessageFormat2.java, FormatFactory.java
>
>
> Discussed on dev@ ( http://mail-archives.apache.org/mod_mbox/commons-dev/200710.mbox/%3c590921.30381.qm@web55103.mail.re4.yahoo.com%3e ); 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.