标签:
java.text.MessageFormat格式化字符串时的小技巧
public static void main(String[] args) throws InterruptedException { MessageFormat form = new MessageFormat( "{2,date,yyyy-MM-dd HH:mm:ss.SSS} The disk \"{1}\" contains {0,number,#.##} file(s).{3}"); int fileCount = 1273273237; String diskName = "MyDisk"; Object[] testArgs = {new Long(fileCount), diskName, new Date(),new Date()}; System.out.println(form.format(testArgs)); }
执行结果: 2016-05-26 13:41:59.162 The disk "MyDisk" contains 1273273237 file(s).16-5-26 下午1:41
java.text.MessageFormat格式化字符串时的小技巧
标签:
原文地址:http://www.cnblogs.com/softidea/p/5530834.html