/*
 * Created on 2005-5-12
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package org.chapter2;

import java.text.MessageFormat;
import java.util.Date;
/**
 * @author Administrator
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class StringFormat {

	public static void main(String[] args) {
		String message = "这时第{1}个问题,当前时间是{0}" ;
		MessageFormat mf = new MessageFormat("这时第{0}个问题,当前时间是{1}");
		Object[] argument = {new Integer(123456),
							new Date()};
		System.out.println(MessageFormat.format(message,argument));
		System.out.println(mf.format(argument));
		try{
		String result = MessageFormat.format(
			     "当前价格为'''{'\"{0,number,currency},当前时间是{1,date}.",
			     argument);
		System.out.println(result);
		}catch(Exception e){
			e.printStackTrace();
		}
		
	}
}
