Code example for ParsePosition

0
        MessageFormat obj = new MessageFormat(pat);
        assertEquals(etalon, obj.format(new Object[] { new Date() }));
    } 
 
    public void test_parseLjava_lang_StringLjava_text_ParsePosition() { 
        ParsePosition pos = new ParsePosition(2);
 
        MessageFormat mf = new MessageFormat("{0}; {0}; {0}");
        String parse = "a; b; c";
        try { 
            mf.parse(parse, null);
            fail("NullPointerException was not thrown.");
        } catch(NullPointerException npe) {
            //expected 
        } 
 
        try { 
            mf.parse(null, pos);
        } catch(NullPointerException npe) {
            fail("NullPointerException was thrown.");
        }