Package java.text

Examples of java.text.MessageFormat.toPattern()


    assertEquals("Wrong date pattern", "{0,date}", format.toPattern());
        format.applyPattern("{0, date, short}");
        assertTrue("Wrong short date format", format.getFormats()[0]
                .equals(DateFormat.getDateInstance(DateFormat.SHORT)));
    assertEquals("Wrong short date pattern",
        "{0,date,short}", format.toPattern());
        format.applyPattern("{0, date, medium}");
        assertTrue("Wrong medium date format", format.getFormats()[0]
                .equals(DateFormat.getDateInstance(DateFormat.MEDIUM)));
    assertEquals("Wrong medium date pattern",
        "{0,date}", format.toPattern());
View Full Code Here


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

        "{0,date}", format.toPattern());
        format.applyPattern("{0, date, long}");
        assertTrue("Wrong long date format", format.getFormats()[0]
                .equals(DateFormat.getDateInstance(DateFormat.LONG)));
    assertEquals("Wrong long date pattern",
        "{0,date,long}", format.toPattern());
        format.applyPattern("{0, date, full}");
        assertTrue("Wrong full date format", format.getFormats()[0]
                .equals(DateFormat.getDateInstance(DateFormat.FULL)));
    assertEquals("Wrong full date pattern",
        "{0,date,full}", format.toPattern());
View Full Code Here

        "{0,date,long}", format.toPattern());
        format.applyPattern("{0, date, full}");
        assertTrue("Wrong full date format", format.getFormats()[0]
                .equals(DateFormat.getDateInstance(DateFormat.FULL)));
    assertEquals("Wrong full date pattern",
        "{0,date,full}", format.toPattern());

        format.applyPattern("{0, date, MMM d {hh:mm:ss}}");
    assertEquals("Wrong time/date format", " MMM d {hh:mm:ss}", ((SimpleDateFormat) (format
        .getFormats()[0])).toPattern());
    assertEquals("Wrong time/date pattern",
View Full Code Here

        format.applyPattern("{0, date, MMM d {hh:mm:ss}}");
    assertEquals("Wrong time/date format", " MMM d {hh:mm:ss}", ((SimpleDateFormat) (format
        .getFormats()[0])).toPattern());
    assertEquals("Wrong time/date pattern",
        "{0,date, MMM d {hh:mm:ss}}", format.toPattern());

        format.applyPattern("{0, number}");
        assertTrue("Wrong number format", format.getFormats()[0]
                .equals(NumberFormat.getNumberInstance()));
    assertEquals("Wrong number pattern",
View Full Code Here

        format.applyPattern("{0, number}");
        assertTrue("Wrong number format", format.getFormats()[0]
                .equals(NumberFormat.getNumberInstance()));
    assertEquals("Wrong number pattern",
        "{0,number}", format.toPattern());
        format.applyPattern("{0, number, currency}");
        assertTrue("Wrong currency number format", format.getFormats()[0]
                .equals(NumberFormat.getCurrencyInstance()));
    assertEquals("Wrong currency number pattern",
        "{0,number,currency}", format.toPattern());
View Full Code Here

        "{0,number}", format.toPattern());
        format.applyPattern("{0, number, currency}");
        assertTrue("Wrong currency number format", format.getFormats()[0]
                .equals(NumberFormat.getCurrencyInstance()));
    assertEquals("Wrong currency number pattern",
        "{0,number,currency}", format.toPattern());
        format.applyPattern("{0, number, percent}");
        assertTrue("Wrong percent number format", format.getFormats()[0]
                .equals(NumberFormat.getPercentInstance()));
    assertEquals("Wrong percent number pattern",
        "{0,number,percent}", format.toPattern());
View Full Code Here

        "{0,number,currency}", format.toPattern());
        format.applyPattern("{0, number, percent}");
        assertTrue("Wrong percent number format", format.getFormats()[0]
                .equals(NumberFormat.getPercentInstance()));
    assertEquals("Wrong percent number pattern",
        "{0,number,percent}", format.toPattern());
        format.applyPattern("{0, number, integer}");
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMaximumFractionDigits(0);
        nf.setParseIntegerOnly(true);
        assertTrue("Wrong integer number format", format.getFormats()[0]
View Full Code Here

        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

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.