Code example for DecimalFormat

Methods: format, isGroupingUsed, setGroupingUsed

0
        } catch (Exception e) {
            fail("Unexpected exception " + e.toString());
        } 
    } 
    public void test_setGroupingUse() { 
        DecimalFormat format = new DecimalFormat();
 
        StringBuffer buf = new StringBuffer();
        format.setGroupingUsed(false);
        format.format(new Long(1970), buf, new FieldPosition(0));
        assertEquals("1970", buf.toString());
        assertFalse(format.isGroupingUsed());
        format.format(new Long(1970), buf, new FieldPosition(0));
        assertEquals("19701970", buf.toString());
        assertFalse(format.isGroupingUsed());
 
        format.setGroupingUsed(true);
        format.format(new Long(1970), buf, new FieldPosition(0));
        assertEquals("197019701,970", buf.toString());
        assertTrue(format.isGroupingUsed());
    } 
 
    public void test_Constructor() { 
        // Test for method java.text.DecimalFormat() 
        // the constructor form that specifies a pattern is equal to the form