Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Your own MessageFormat flavors

  Asked By: Ibthaj    Date: May 17    Category: Java    Views: 541
  

MessageFormat is very useful to convert data into strings, like:

s = MessageFormat.format("today is {0,date} and the time is {0,time}",
new Object[] { new Date() });

I'd like to add my own custom format, like so:

s = MessageFormat.format("today is {0,date} and the temperature is
{1,temp}", new Object[] { new Date(), new Temperature() });

I don't see any factory registries or static methods in MessageFormat
where I can add my own types.

Does anyone know of a way of doing this. Perhaps I'm missing
something. Perhaps someone has seen a rewrite of a customizable
MessageFormat somewhere?

Share: 



Tagged: