Code example for NumberFormat

Methods: format

0
        assertTrue("Object is not instance of NumberFormat",
                format instanceof NumberFormat);
 
        assertEquals(
                "Test1: NumberFormat.getInstance().format(1234567890.0987654321) returned wrong value", 
                "1,234,567,890.099", format.format(1234567890.0987654321));
        assertEquals(
                "Test2: ((DecimalFormat) NumberFormat.getInstance()).toPattern returned wrong value", 
                "#,##0.###", ((DecimalFormat) format).toPattern());
        assertEquals(
                "Test3: NumberFormat.getInstance().format(123456789) returned wrong value", 
                "123,456,789", format.format(123456789));
    } 
 
    public void test_getInstanceLjava_util_Locale() { 
        Locale testLocale = new Locale("de", "CH");
        Locale.setDefault(Locale.US);
        if (Support_Locale.isLocaleAvailable(testLocale)) {
            NumberFormat format = NumberFormat.getInstance(testLocale);
 
            assertNotSame(null, format);