Reputation: 1081
We are using velocity as template. We use NumberTool to format number in vm files.
For example
$!{NUMBER.format('#,##0',$!{amount})} 円
Expected output is for example 9,900円 . It works in almost 99.9999% of the cases. But sometimes for example once in a few months it displays as 9.900円 in our web page.
Does anyone face same problem ? Is there any bug in NumberTool related to Locale or some other issue?
Upvotes: 1
Views: 963
Reputation: 11
or You can set Locale of you choice as
VelocityContext context = new VelocityContext();
NumberTool nt = new NumberTool();
HashedMap vp = new HashedMap();
vp.put("locale",new Locale("en","IN"));
nt.configure(vp);
context.put("numberTool", nt);
Upvotes: 0
Reputation: 4130
The decimals separator can depend on the locale.
To avoid this, you can configure a specific locale to the number tool. For instance, when using a tools.xml
file:
<tool key="number" class="org.apache.velocity.tools.generic.NumberTool" locale="en_US"/>
Or you can specify the Locale using Java:
numberTool.setLocale("en_US")
Upvotes: 1