替换数字上的减号和 replace/enclose 括号中的负数
Replace the minus sign on a number and replace/enclose the negative number in a parentheses
Freemarker 代码:
${customrecord_line.amount?string("(,##0.00)")}
实际结果 = -1234.56
预期结果 = (1234.56)
注:customrecord_line.amount代表金额
您可以使用;
来分隔非负数和负数的模式。如果您从专用负片模式中省略 -
,则它不会自动添加到输出中。参见 https://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html。
示例:
<#setting number_format="##0.00;(##0.00)">
${1.5}
${-1.5}
输出:
1.50
(1.50)
当然,"##0.00;(##0.00)"
模式也可以与 ?string(...)
一起使用。只指定一次更方便。 (此外,如果您可以调整 FreeMarker 配置设置,则可以定义自定义数字格式别名,这使得这更易于管理。请参阅 http://freemarker.org/docs/pgui_config_custom_formats.html)。
Freemarker 代码:
${customrecord_line.amount?string("(,##0.00)")}
实际结果 = -1234.56
预期结果 = (1234.56)
注:customrecord_line.amount代表金额
您可以使用;
来分隔非负数和负数的模式。如果您从专用负片模式中省略 -
,则它不会自动添加到输出中。参见 https://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html。
示例:
<#setting number_format="##0.00;(##0.00)">
${1.5}
${-1.5}
输出:
1.50
(1.50)
当然,"##0.00;(##0.00)"
模式也可以与 ?string(...)
一起使用。只指定一次更方便。 (此外,如果您可以调整 FreeMarker 配置设置,则可以定义自定义数字格式别名,这使得这更易于管理。请参阅 http://freemarker.org/docs/pgui_config_custom_formats.html)。