Code example for MessageFormat

Methods: format

0
                "test_formatLjava_lang_ObjectLjava_lang_StringBufferLjava_text_FieldPosition") 
                .t_format_with_FieldPosition(); 
 
        String pattern = "On {4,date} at {3,time}, he ate {2,number, integer} " +
                "hamburger{2,choice,1#|1<s}."; 
        MessageFormat format = new MessageFormat(pattern, Locale.US);
 
        Object[] objects = new Object[] { "", new Integer(3), 8, ""};
 
        try { 
            format.format(objects, new StringBuffer(),
                    new FieldPosition(DateFormat.Field.AM_PM));
            fail("IllegalArgumentException was not thrown.");
        } catch(IllegalArgumentException iae) {
            //expected 
        } 
    } 
 
    public void test_setFormats$Ljava_text_Format() { 
        try { 
Contextual code suggestions in your IDE  Get Codota for Java