This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

MessageFormat  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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

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

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.

Regards,
Manohar
 
Rancher
Posts: 42975
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!