Package com.ibm.icu.text

Examples of com.ibm.icu.text.DecimalFormatSymbols


    /*
     * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getInternationalCurrencySymbol()'
     */
    public void testGetInternationalCurrencySymbol() {
        DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
        assertEquals("USD", dfs.getInternationalCurrencySymbol());
    }
View Full Code Here


    /*
     * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setInternationalCurrencySymbol(String)'
     */
    public void testSetInternationalCurrencySymbol() {
        DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
        String value = dfs.getInternationalCurrencySymbol();
        String value1 = value + "!";
        dfs.setInternationalCurrencySymbol(value1);
        String result = dfs.getInternationalCurrencySymbol();
        assertNotEqual(value, result);
        assertEquals(value1, result);
    }
View Full Code Here

    /*
     * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getMonetaryDecimalSeparator()'
     */
    public void testGetMonetaryDecimalSeparator() {
        DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
        assertEquals('.', dfs.getMonetaryDecimalSeparator());
    }
View Full Code Here

    /*
     * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setMonetaryDecimalSeparator(char)'
     */
    public void testSetMonetaryDecimalSeparator() {
        DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
        char value = dfs.getMonetaryDecimalSeparator();
        char value1 = (char)(value + 1);
        dfs.setMonetaryDecimalSeparator(value1);
        char result = dfs.getMonetaryDecimalSeparator();
        assertNotEqual(value, result);
        assertEquals(value1, result);
    }
View Full Code Here

    /*
     * Test method for 'com.ibm.icu.text.DecimalFormat.DecimalFormat(String, DecimalFormatSymbols)'
     */
    public void testDecimalFormatStringDecimalFormatSymbols() {
        DecimalFormatSymbols sym = new DecimalFormatSymbols(Locale.FRANCE);
        DecimalFormat df = new DecimalFormat("#,##0.000", sym);
        assertEquals("23,330", df.format(dsmall));
    }
View Full Code Here

    /*
     * Test method for 'com.ibm.icu.text.DecimalFormat.getDecimalFormatSymbols()'
     */
    public void testGetDecimalFormatSymbols() {
        DecimalFormatSymbols sym = new DecimalFormatSymbols(Locale.FRANCE);
        DecimalFormat df = new DecimalFormat("#,##0.000", sym);
        assertEquals(sym, df.getDecimalFormatSymbols());
    }
View Full Code Here

    /*
     * Test method for 'com.ibm.icu.text.DecimalFormat.setDecimalFormatSymbols(DecimalFormatSymbols)'
     */
    public void testSetDecimalFormatSymbols() {
        DecimalFormat df = new DecimalFormat();
        df.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.FRANCE));
        assertEquals("23,33", df.format(dsmall));
    }
View Full Code Here

    /*
     * Test method for 'com.ibm.icu.text.DecimalFormat.toLocalizedPattern()'
     */
    public void testToLocalizedPattern() {
        DecimalFormat df = new DecimalFormat("#,##0.##", new DecimalFormatSymbols(Locale.FRANCE));
        assertEquals("#,##0.##", df.toPattern());
        assertEquals("#\u00a0##0,##", df.toLocalizedPattern());
    }
View Full Code Here

    /*
     * Test method for 'com.ibm.icu.text.DecimalFormat.applyLocalizedPattern(String)'
     */
    public void testApplyLocalizedPattern() {
        DecimalFormat df = new DecimalFormat("#,##0.##", new DecimalFormatSymbols(Locale.FRANCE));
        df.applyLocalizedPattern("#\u00a00,#");
        assertEquals("1\u00a02\u00a03,4", df.format(123.4));
    }
View Full Code Here

            pat = new DecimalFormat(pattern);
        } catch (IllegalArgumentException e) {
            errln("ERROR: Could not create DecimalFormat (pattern)");
        }

        DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.FRENCH);

        DecimalFormat cust1 = new DecimalFormat(pattern, symbols);

        // ======= Test clone(), assignment, and equality

        logln("Testing clone() and equality operators");

        Format clone = (Format) def.clone();
        if (!def.equals(clone)) {
            errln("ERROR: Clone() failed");
        }

        // ======= Test various format() methods

        logln("Testing various format() methods");

        //        final double d = -10456.0037; // this appears as -10456.003700000001 on NT
        //        final double d = -1.04560037e-4; // this appears as -1.0456003700000002E-4 on NT
        final double d = -10456.00370000000000; // this works!
        final long l = 100000000;
        logln("" + Double.toString(d) + " is the double value");

        StringBuffer res1 = new StringBuffer();
        StringBuffer res2 = new StringBuffer();
        StringBuffer res3 = new StringBuffer();
        StringBuffer res4 = new StringBuffer();
        FieldPosition pos1 = new FieldPosition(0);
        FieldPosition pos2 = new FieldPosition(0);
        FieldPosition pos3 = new FieldPosition(0);
        FieldPosition pos4 = new FieldPosition(0);

        res1 = def.format(d, res1, pos1);
        logln("" + Double.toString(d) + " formatted to " + res1);

        res2 = pat.format(l, res2, pos2);
        logln("" + l + " formatted to " + res2);

        res3 = cust1.format(d, res3, pos3);
        logln("" + Double.toString(d) + " formatted to " + res3);

        res4 = cust1.format(l, res4, pos4);
        logln("" + l + " formatted to " + res4);

        // ======= Test parse()

        logln("Testing parse()");

        String text = new String("-10,456.0037");
        ParsePosition pos = new ParsePosition(0);
        String patt = new String("#,##0.#");
        pat.applyPattern(patt);
        double d2 = pat.parse(text, pos).doubleValue();
        if (d2 != d) {
            errln(
                "ERROR: Roundtrip failed (via parse(" + Double.toString(d2) + " != " + Double.toString(d) + ")) for " + text);
        }
        logln(text + " parsed into " + (long) d2);

        // ======= Test getters and setters

        logln("Testing getters and setters");

        final DecimalFormatSymbols syms = pat.getDecimalFormatSymbols();
        def.setDecimalFormatSymbols(syms);
        if (!pat.getDecimalFormatSymbols().equals(def.getDecimalFormatSymbols())) {
            errln("ERROR: set DecimalFormatSymbols() failed");
        }
View Full Code Here

TOP

Related Classes of com.ibm.icu.text.DecimalFormatSymbols

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.