Code example for FieldPosition

Methods: equals, setBeginIndex

0
        FieldPosition fpos = new FieldPosition(DateFormat.Field.MONTH,
                DateFormat.MONTH_FIELD);
        assertSame("Constructor failed to set field attribute!",
                DateFormat.Field.MONTH, fpos.getFieldAttribute());
        assertEquals("Test1: Constructor failed to set field identifier!",
                DateFormat.MONTH_FIELD, fpos.getField());
 
        // test special cases 
        FieldPosition fpos2 = new FieldPosition(DateFormat.Field.HOUR1,
                DateFormat.HOUR1_FIELD);
        assertSame("Constructor failed to set field attribute!",
                DateFormat.Field.HOUR1, fpos2.getFieldAttribute());
        assertEquals("Test2: Constructor failed to set field identifier!",
                DateFormat.HOUR1_FIELD, fpos2.getField());
 
        FieldPosition fpos3 = new FieldPosition(DateFormat.Field.TIME_ZONE,
                DateFormat.MONTH_FIELD);
        assertSame("Constructor failed to set field attribute!",
                DateFormat.Field.TIME_ZONE, fpos3.getFieldAttribute());
        assertEquals("Test3: Constructor failed to set field identifier!",
                DateFormat.MONTH_FIELD, fpos3.getField());
    } 
 
    /** 
     * @tests java.text.FieldPosition#equals(java.lang.Object) 
     */ 
    @TestTargetNew( 
        level = TestLevel.COMPLETE, 
        notes = "", 
        method = "equals",