【问题标题】:Display Indian Currency in Thymeleaf + Spring Boot在 Thymeleaf + Spring Boot 中显示印度货币
【发布时间】:2020-04-25 22:26:26
【问题描述】:

我正在尝试使用 SpringBoot + Thymeleaf 显示印度货币格式。 我在 HTML 中使用了以下代码来显示它

<td th:text="${#numbers.formatCurrency(revenueDetailsDto.getTotalCommissionablePremium())}"></td>

  @Bean
    public LocaleResolver localeResolver() {
        SessionLocaleResolver slr = new SessionLocaleResolver();
        slr.setDefaultLocale(new Locale("en", "IN"));
        return slr;
    }

这将字符串显示为- 1,599,176.00 卢比。

但是,我想要印度数字格式的结果,例如- 卢比。 15,99,176.00 .

你知道如何实现它吗?

【问题讨论】:

  • 这似乎是一个错误。如果您使用普通 Java 进行测试并打印货币会怎样,如下所述:tutorials.jenkov.com/java-internationalization/…
  • 我尝试使用下面的代码,但同样的问题 NumberFormat numberFormat = NumberFormat.getInstance(new Locale("en", "in")); System.out.println(numberFormat.format(73746842.00));

标签: spring-boot thymeleaf


【解决方案1】:

Java NumberFomat 似乎不支持这种印度货币格式。

见:Displaying Currency in Indian Numbering Format

您需要在服务器端格式化。

【讨论】:

    猜你喜欢
    • 2018-11-09
    • 2011-07-19
    • 2015-07-24
    • 1970-01-01
    • 2012-01-22
    • 2018-03-23
    • 1970-01-01
    • 2012-04-20
    • 1970-01-01
    相关资源
    最近更新 更多