今天码字的时候,不小心把MessageFormat.format() 写成Messages.format(), 才意识到Messages.format()虽然长得跟MessageFormat.format()很像,但是二者的功能不同。看了Messages.format()的源码,应该是要为某个property 赋值,但是奇怪的是网络上我居然没找到任何跟Messages.format()相关的信息,待之后有机会找到再补上。
import com.sun.xml.internal.bind.marshaller.Messages;
import java.text.MessageFormat;
/**
* Created by vickyy on 5/22/2018.
*/
public class Demo {
public static void main(String[] args) {
String carrier = "UPS";
String org = "MG";
System.out.println(MessageFormat.format("{0} is not the carrier of {1}.",carrier, org));
System.out.println(Messages.format(??);
}
}