java

MessageFormater

1
2
3
4
5
6
7
8
9
10
FormatElement:
{ ArgumentIndex }:是从0开始的入参位置索引。
{ ArgumentIndex , FormatType }
{ ArgumentIndex , FormatType , FormatStyle }

Object[] names = new Object[]{"12"};
// 预编译版,可重复使用
new MessageFormat("na{0}{1,number}").format(names);
// 普通版本
MessageFormat.format("name{0}", 1, 2);

参考

  1. Java中MessageFormat的使用