Package java.text

Examples of java.text.MessageFormat.toPattern()


        nf.setMaximumFractionDigits(0);
        nf.setParseIntegerOnly(true);
        assertTrue("Wrong integer number format", format.getFormats()[0]
                .equals(nf));
    assertEquals("Wrong integer number pattern",
        "{0,number,integer}", format.toPattern());

        format.applyPattern("{0, number, {'#'}##0.0E0}");

        /*
         * TODO validate these assertions
View Full Code Here


        format.applyPattern("{0, choice,0#no|1#one|2#{1,number}}");
    assertEquals("Wrong choice format",
       
            "0.0#no|1.0#one|2.0#{1,number}", ((ChoiceFormat) format.getFormats()[0]).toPattern());
    assertEquals("Wrong choice pattern",
        "{0,choice,0.0#no|1.0#one|2.0#{1,number}}", format.toPattern());
    assertEquals("Wrong formatted choice", "3.6", format.format(
        new Object[] { new Integer(2), new Float(3.6) }));

        try {
            format.applyPattern("WRONG MESSAGE FORMAT {0,number,{}");
View Full Code Here

     */
    public void test_toPattern() {
        // Test for method java.lang.String java.text.MessageFormat.toPattern()
        String pattern = "[{0}]";
        MessageFormat mf = new MessageFormat(pattern);
        assertTrue("Wrong pattern", mf.toPattern().equals(pattern));
       
        // Regression for HARMONY-59
        new MessageFormat("CHOICE {1,choice}").toPattern();
    }

View Full Code Here

        String expected = "xx " + DateFormat.getInstance().format(date);
        assertTrue("Invalid date:\n" + result + "\n" + expected, result
                .equals(expected));
        format = new MessageFormat("{0,date}{1,time}{2,number,integer}");
        format.applyPattern("nothing");
    assertEquals("Found formats", "nothing", format.toPattern());

        format.applyPattern("{0}");
    assertNull("Wrong format", format.getFormats()[0]);
    assertEquals("Wrong pattern", "{0}", format.toPattern());
View Full Code Here

        format.applyPattern("nothing");
    assertEquals("Found formats", "nothing", format.toPattern());

        format.applyPattern("{0}");
    assertNull("Wrong format", format.getFormats()[0]);
    assertEquals("Wrong pattern", "{0}", format.toPattern());

        format.applyPattern("{0, \t\u001ftime }");
        assertTrue("Wrong time format", format.getFormats()[0]
                .equals(DateFormat.getTimeInstance()));
    assertEquals("Wrong time pattern", "{0,time}", format.toPattern());
View Full Code Here

    assertEquals("Wrong pattern", "{0}", format.toPattern());

        format.applyPattern("{0, \t\u001ftime }");
        assertTrue("Wrong time format", format.getFormats()[0]
                .equals(DateFormat.getTimeInstance()));
    assertEquals("Wrong time pattern", "{0,time}", format.toPattern());
        format.applyPattern("{0,Time, Short\n}");
        assertTrue("Wrong short time format", format.getFormats()[0]
                .equals(DateFormat.getTimeInstance(DateFormat.SHORT)));
    assertEquals("Wrong short time pattern",
        "{0,time,short}", format.toPattern());
View Full Code Here

    assertEquals("Wrong time pattern", "{0,time}", format.toPattern());
        format.applyPattern("{0,Time, Short\n}");
        assertTrue("Wrong short time format", format.getFormats()[0]
                .equals(DateFormat.getTimeInstance(DateFormat.SHORT)));
    assertEquals("Wrong short time pattern",
        "{0,time,short}", format.toPattern());
        format.applyPattern("{0,TIME,\nmedium  }");
        assertTrue("Wrong medium time format", format.getFormats()[0]
                .equals(DateFormat.getTimeInstance(DateFormat.MEDIUM)));
    assertEquals("Wrong medium time pattern",
        "{0,time}", format.toPattern());
View Full Code Here

        "{0,time,short}", format.toPattern());
        format.applyPattern("{0,TIME,\nmedium  }");
        assertTrue("Wrong medium time format", format.getFormats()[0]
                .equals(DateFormat.getTimeInstance(DateFormat.MEDIUM)));
    assertEquals("Wrong medium time pattern",
        "{0,time}", format.toPattern());
        format.applyPattern("{0,time,LONG}");
        assertTrue("Wrong long time format", format.getFormats()[0]
                .equals(DateFormat.getTimeInstance(DateFormat.LONG)));
    assertEquals("Wrong long time pattern",
        "{0,time,long}", format.toPattern());
View Full Code Here

        "{0,time}", format.toPattern());
        format.applyPattern("{0,time,LONG}");
        assertTrue("Wrong long time format", format.getFormats()[0]
                .equals(DateFormat.getTimeInstance(DateFormat.LONG)));
    assertEquals("Wrong long time pattern",
        "{0,time,long}", format.toPattern());
        format.setLocale(Locale.FRENCH); // use French since English has the
        // same LONG and FULL time patterns
        format.applyPattern("{0,time, Full}");
        assertTrue("Wrong full time format", format.getFormats()[0]
                .equals(DateFormat.getTimeInstance(DateFormat.FULL,
View Full Code Here

        format.applyPattern("{0,time, Full}");
        assertTrue("Wrong full time format", format.getFormats()[0]
                .equals(DateFormat.getTimeInstance(DateFormat.FULL,
                        Locale.FRENCH)));
    assertEquals("Wrong full time pattern",
        "{0,time,full}", format.toPattern());
        format.setLocale(Locale.getDefault());

        format.applyPattern("{0, date}");
        assertTrue("Wrong date format", format.getFormats()[0]
                .equals(DateFormat.getDateInstance()));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.