Java 常用工具类

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); 

原文地址:https://www.cnblogs.com/leonkobe/p/5687818.html