new MessageFormat(String pattern) : MessageFormat « java.text « Java by API






new MessageFormat(String pattern)

 


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

class MessageFormatApp {
  public static void main(String args[]) {
    String pattern = "The time is {0,time} and ";
    pattern += "your number is {1,number}.";
    MessageFormat format = new MessageFormat(pattern);
    Object objects[] = { new Date(), new Integer((int) (Math.random() * 1000)) };
    String formattedOutput = format.format(objects);
    System.out.println(formattedOutput);
  }
}

   
  








Related examples in the same category

1.MessageFormat: format(String pattern, Object... arguments)
2.MessageFormat: setLocale(Locale locale)