Integer gets comma-formatted when it is retrieved from ResourceBundle

year.of.birth={0} was born on {1} If I pass 2000 or 2008 to {1} the value gets parsed as 2,000 or 2,008. 

I don't want commas to be part of my translated string. How can I avoid this?

+7
source share
1 answer

A simple way is to pass them as strings:

 msg.format("year.of.birth", name, String.valueOf(2008)); 

An alternative is to specify the format of the number in the message resource (but I would only do this if the format may vary depending on the locales):

 year.of.birth={0} was born in {1,number,####} 
+15
source

All Articles