相关疑难解决方法(0)

Java 的 MessageFormat 没有本地化小写日期中的葡萄牙语月份

月份名称以大写字母而不是小写字母开头,正如它们应该的那样

我在本地机器上运行的一些示例代码:

  Locale portugal = new Locale("pt");
  Locale brazil = new Locale("pt", "BR");
  Locale france = new Locale("fr", "FR");

  Object[] params = new Object[] { new Date() };
  String pattern = "Today is {0,date,long}!";

  MessageFormat ptFormat = new MessageFormat(pattern, portugal);
  MessageFormat brFormat = new MessageFormat(pattern, brazil);
  MessageFormat frFormat = new MessageFormat(pattern, france);

  StringBuffer ptResult = ptFormat.format(params, new StringBuffer(), new FieldPosition(0));
  StringBuffer brResult = brFormat.format(params, new StringBuffer(), new FieldPosition(0));
  StringBuffer frResult = frFormat.format(params, new StringBuffer(), null);

  System.out.println("Portugal result: " …
Run Code Online (Sandbox Code Playgroud)

java localization date messageformat

2
推荐指数
1
解决办法
1144
查看次数

标签 统计

date ×1

java ×1

localization ×1

messageformat ×1