MessageFormat用来格式化一个消息,通常是一个字符串,比如:
String str = "I'm not a {0}, age is {1,number,short}", height is {2,number,#.#};
// hello adobe ,hehe google
String str = "I'm not a {0}, age is {1,number,short}", height is {2,number,#.#};
String text="hello {0},hehe{1}";
MessageFormat mf=new MessageFormat(text);
String value=MessageFormat.format(new Object[]{"adobe","goole"});
System.out.println(value);
// hello adobe ,hehe google