【发布时间】:2020-01-10 03:48:15
【问题描述】:
如何将整数中的美分值显示为thymleaf中的货币?
我正在集成一个银行 API,该 API 以美分返回所有金额。我使用 thymleaf 作为模板引擎,无法在前端正确显示金额。
例如:
来自服务器的值 = 16417
预期输出 = 164.17
我尝试了以下表达式,但无法获得预期的输出。
1)
<span th:text="${#numbers.formatDecimal(page.amount, 0, 'COMMA', 2, 'POINT')}"></span>
输出:16,417.00
2)
<span th:text="${#numbers.formatDecimal(page.amount/100, 0, 'COMMA', 2, 'POINT')}"></span>
输出:164.00
3)
<span th:text="${#numbers.formatCurrency(page.amount)}"></span>
输出:$16,417.00
4)
<span th:text="${#numbers.formatCurrency(page.amount/100)}"></span>
输出:$164.00
【问题讨论】:
标签: java html spring-boot thymeleaf