`

MessageFormat入门实例

阅读更多
/**
 * MessageFormat入门实例
 */
package com.mytest.messageformat;

import java.text.MessageFormat;
import java.util.Date;


/**
 * @author 安徽程
 *
 * 18 Dec, 2011 1:55:32 PM
 */
public class MessageFormatTutorial {
	
	public static void testMessageFormat(String name,double age,Date date){
		System.out.println(MessageFormat.format("my name is {0} ,my age is {1,number,##.#} ,time is {2,time}",name,age,date));
	}
	
	public static void main(String args[]){
		MessageFormatTutorial.testMessageFormat("ahcheng",23.52,new Date());
		
	}

}
 

 

 

输出为:my name is ahcheng ,my age is 23.5 ,time is 2:13:23 PM

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics