This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes MessageFormat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "MessageFormat" Watch "MessageFormat" New topic


Manohar Saddala

Joined: Jul 11, 2007
Posts: 12

I had issue with MessageFormat. Below is the code...

String msg = "Hello %%0%%";
Object[] objArr = {"ALL"};
MessageFormat msgFormat = new MessageFormat(msg);

The output is coming as : Hello %%testvalue%%
But what i expected is : Hello ALL

But i am getting the expected output when the msg is "Hello {0}"

I cant change %%0%% to {0} because the msg is specified by client.

Can any one help regarding this.


Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41046
Hello "Manohar S "-

On your way in you may have missed that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.

The message format isn't specified by your client, it's specified by the MessageFormat class. If you want to use that, you'll have to use its syntax.

If the "%%0%%" syntax is all you have to support, then it would seem easy to change that to "{0}" using regular expressions.

Ping & DNS - my free Android networking tools app
I agree. Here's the link:
subject: MessageFormat
Similar Threads
array store exception
Custom Strings
array of objects
Multiplication Table
StringSplit regex question: missing part of my string?