Use MessageFormat to format a sentence : Message Format « I18N « Java Tutorial

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 lucky number is {1,number}.";
    MessageFormat format = new MessageFormat(pattern);
    Object objects[] = { new Date(), new Integer((int) (Math.random() * 1000)) };
    String formattedOutput = format.format(objects);

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