Code example for NumberFormat

Methods: format

0
        assertTrue("Object is not instance of NumberFormat",
                format instanceof NumberFormat);
 
        assertEquals(
                "Test1: NumberFormat.getCurrencyInstance().format(35.76) returned wrong value", 
                "$35.76", format.format(35.76));
        assertEquals(
                "Test2: NumberFormat.getCurrencyInstance().format(123456.789) returned wrong value", 
                "$123,456.79", format.format(123456.789));
        assertEquals(
                "Test3: NumberFormat.getCurrencyInstance().format(0.1) returned wrong value", 
                "$0.10", format.format(0.1));
        assertEquals(
                "Test4: NumberFormat.getCurrencyInstance().format(0.999) returned wrong value", 
                "$1.00", format.format(0.999));
    } 
 
    public void test_getCurrencyInstanceLjava_util_Locale() { 
        Locale usLocale = Locale.US;
        NumberFormat format = NumberFormat.getCurrencyInstance(usLocale);
Connect your IDE to all the code out there  Get Codota for Java