Code example for NumberFormat

Methods: format

0
        if (Support_Locale.isLocaleAvailable(deLocale)) {
            NumberFormat format = NumberFormat.getNumberInstance(deLocale);
            assertNotSame("Instance is null", null, format);
            assertTrue("Object is not instance of NumberFormat", format instanceof NumberFormat);
 
            assertEquals("-1'234'567'890.099", format.format(-1234567890.0987654321));
            assertEquals("#,##0.###", ((DecimalFormat) format).toPattern());
            assertEquals("123'456'789", format.format(123456789));
        } 
        try { 
            NumberFormat.getInstance(null);
            fail("java.lang.NullPointerException is not thrown");
        } catch (java.lang.NullPointerException expected) {
        } 
    } 
 
    public void test_getPercentInstance() { 
        Locale.setDefault(Locale.US);
        NumberFormat format = NumberFormat.getPercentInstance();
 
Stop searching for code, let great code find you!  Add Codota to your java IDE