【发布时间】:2015-02-05 09:09:32
【问题描述】:
我在我的项目中使用 Joda Money.class 作为货币。
我正在使用 NumberTool 来格式化 Velocity 模板中的数字。
context.put("number", new NumberTool());
我将 Money 值转换为整数,以便将这些值放入 Velocity 模板中。
示例:
// 123435 €1234.35
priceInCents = price.getAmountMinorInt();
我想在 Velocity 模板中格式化这个值,如下所示:
1.234,35
我该如何做到这一点?
我尝试了以下几种情况:
$number.format('#0,00', $price) //Output: 1234,35
$number.format('#0.00', $price) //Output: 123435.00
$number.format('#00,00', $price) //Output: 12,34,35
$number.format('#00.00', $price) //Output: 123435.00
$number.format('#000,00', $price) //Output: 12,34,35
$number.format('#000.00', $price) //Output: 123435.00
【问题讨论】:
标签: java formatting velocity