MessageFormat
FormatElement:
{ ArgumentIndex }
{ ArgumentIndex , FormatType }
{ ArgumentIndex , FormatType , FormatStyle }
FormatType:
number
date
time
choice(需要使用ChoiceFormat)
FormatStyle:
short
medium
long
full
integer
currency
percent
SubformatPattern(子模式)
String str = "I‘m not a {0}, age is {1,number,short}", height is {2,number,#.#};
String message = "oh, ‘{0}‘ is a pig";
Object[] array = new Object[]{"ZhangSan"};
String value = MessageFormat.format(message, array);
System.out.println(value);
时间: 2024-11-05 15:40:26