Code example for SimpleDateFormat

Methods: get2DigitYearStart, set2DigitYearStart

0
    private static final TimeZone AUSTRALIA_LORD_HOWE = TimeZone.getTimeZone("Australia/Lord_Howe");
 
    // The RI fails this test. 
    public void test2DigitYearStartIsCloned() throws Exception { 
        // Test that get2DigitYearStart returns a clone. 
        SimpleDateFormat sdf = new SimpleDateFormat();
        Date originalDate = sdf.get2DigitYearStart();
        assertNotSame(sdf.get2DigitYearStart(), originalDate);
        assertEquals(sdf.get2DigitYearStart(), originalDate);
        originalDate.setTime(0);
        assertFalse(sdf.get2DigitYearStart().equals(originalDate));
        // Test that set2DigitYearStart takes a clone. 
        Date newDate = new Date();
        sdf.set2DigitYearStart(newDate);
        assertNotSame(sdf.get2DigitYearStart(), newDate);
        assertEquals(sdf.get2DigitYearStart(), newDate);
        newDate.setTime(0);
        assertFalse(sdf.get2DigitYearStart().equals(newDate));
    } 
 
    // The RI fails this test because this is an ICU-compatible Android extension. 
    // Necessary for correct localization in various languages (http://b/2633414). 
    public void testStandAloneNames() throws Exception {