Substitute tokens in a String : Message Format « I18N « Java Tutorial






import java.text.MessageFormat;

public class Main {
  public static void main(String[] argv) {

    Object[] params = new Object[] { "hello", "!" };
    System.out.println(MessageFormat.format("{0} world {1}", params));
  }
}
//hello world !








13.12.Message Format
13.12.1.Use MessageFormat to format a sentence
13.12.2.Date Number Sample
13.12.3.Substitute tokens in a String
13.12.4.Formatting a Message Containing a Number
13.12.5.Format message with Integer fillers
13.12.6.Use a custom format
13.12.7.Floating point numbers
13.12.8.Currency number format
13.12.9.Percent value format
13.12.10.Formatting a Message Containing a Time
13.12.11.Format Date() in short format
13.12.12.Format Date() value in medium format
13.12.13.Format Date() in long
13.12.14.Format Date value in full length
13.12.15.Use a custom format for Date value
13.12.16.Formatting a Message Containing a Date
13.12.17.Combine date value in a sentence
13.12.18.Set MessageFormat to Locale.US