Example usage for java.text MessageFormat format

List of usage examples for java.text MessageFormat format

Introduction

In this page you can find the example usage for java.text MessageFormat format.

Prototype

public static String format(String pattern, Object... arguments) 

Source Link

Document

Creates a MessageFormat with the given pattern and uses it to format the given arguments.

Usage

From source file:Main.java

public static void main(String[] argv) {

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

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Object[] params = new Object[] { new Integer(123), new Integer(1234) };
    String msg = MessageFormat.format("{0,number,#} a''s and {1,number,#} b''s", params);
    System.out.println(msg);//from w  w w . j av a 2 s  .  c  o  m
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Object[] params = new Object[] { new Integer(123), new Integer(1234) };
    String msg = MessageFormat.format("{0,number} a''s and {1,number} b''s", params);
    System.out.println(msg);//from   w  w  w . j  a  va  2s.com
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    Object[] params = new Object[] { new Integer(123), new Integer(1234) };
    String msg = MessageFormat.format("{0} a''s and {1} b''s", params);
    System.out.println(msg);//from w  w w .  ja v a2s .  c om
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    Object[] params = new Object[] { new Double(123.45), new Double(1234.56) };
    String msg = MessageFormat.format("{0,number,currency} a''s and {1,number,currency} b''s", params);
    System.out.println(msg);/*from  www .java 2  s .c o m*/

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Object[] params = new Object[] { new Date(), new Date(0) };
    String msg = MessageFormat.format("Today is {0,date,full} and UTC of 0 is {1,date,full}", params);
    System.out.println(msg);//from   w  ww  .  j  a va 2s  .c o  m
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Object[] params = new Object[] { new Date(), new Date(0) };
    String msg = MessageFormat.format("{0,time,short} and UTC of 0 is {1,time,short}", params);
    System.out.println(msg);//from   w  w w . j  ava2  s.c o m
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    Object[] params = new Object[] { new Double(123.45), new Double(1234.56) };
    String msg = MessageFormat.format("{0,number,percent} a''s and {1,number,percent} b''s", params);

    System.out.println(msg);/*from   ww w  . j a  va2  s .  c  o m*/

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Object[] params = new Object[] { new Date(), new Date(0) };
    String msg = MessageFormat.format("Today is {0} and UTC of 0 is {1}", params);

    System.out.println(msg);/*  ww w  .  j a v a 2  s.com*/
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Object[] params = new Object[] { new Date(), new Date(0) };
    String msg = MessageFormat.format("Today is {0,date} and UTC of 0 is {1,date}", params);

    System.out.println(msg);// ww  w.  j a  v a 2 s.com
}