Code example for SimpleDateFormat

Methods: format, getClass, getDateFormatSymbols, toPattern

0
        try { 
            new SimpleDateFormat(null, symbols);
            fail("NullPointerException was not thrown.");
        } catch(NullPointerException npe) {
            //expected 
        } 
 
        try { 
            new SimpleDateFormat("eee", symbols);
            fail("IllegalArgumentException was not thrown.");
        } catch(IllegalArgumentException iae) {
            //expected 
        } 
    } 
 
    public void test_ConstructorLjava_lang_StringLjava_util_Locale() { 
        // Test for method java.text.SimpleDateFormat(java.lang.String, 
        // java.util.Locale) 
        SimpleDateFormat f2 = new SimpleDateFormat("'yyyy' MM yy",
                Locale.GERMAN);
        assertTrue("Wrong class", f2.getClass() == SimpleDateFormat.class);