MessageFormatReuse.java Source code

Java tutorial

Introduction

Here is the source code for MessageFormatReuse.java

Source

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

public class MessageFormatReuse {
    public static void main(String args[]) {
        String pattern = "{0}K was deleted on {1}.";
        MessageFormat formatter = new MessageFormat(pattern);

        Double kb = new Double(3.5);
        Date today = new Date();
        Object[] arguments = { kb, today };

        formatter.setLocale(Locale.US);
        System.out.println(formatter.format(arguments));
    }
}