Package java.text

Examples of java.text.MessageFormat.applyPattern()


        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


        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",
        "{0,date, MMM d {hh:mm:ss}}", format.toPattern());
View Full Code Here

    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",
        "{0,number}", format.toPattern());
        format.applyPattern("{0, number, currency}");
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());
        format.applyPattern("{0, number, percent}");
View Full Code Here

        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());
        format.applyPattern("{0, number, integer}");
View Full Code Here

        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]
                .equals(nf));
View Full Code Here

     */
    private MessageFormat createMessageFormat(String pattern, Locale locale) {
        MessageFormat result = new MessageFormat(pattern);
        if (locale != null) {
            result.setLocale(locale);
            result.applyPattern(pattern);
        }
        return result;
    }

    // ------------------------ Test Formats ------------------------
View Full Code Here

     */
    public void test_applyPatternLjava_lang_String() {
        // Test for method void
        // java.text.MessageFormat.applyPattern(java.lang.String)
        MessageFormat format = new MessageFormat("test");
        format.applyPattern("xx {0}");
    assertEquals("Invalid number", "xx 46", format.format(
        new Object[] { new Integer(46) }));
        Date date = new Date();
        String result = format.format(new Object[] { date });
        String expected = "xx " + DateFormat.getInstance().format(date);
View Full Code Here

        String result = format.format(new Object[] { date });
        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

                .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());

        format.applyPattern("{0, \t\u001ftime }");
        assertTrue("Wrong time format", format.getFormats()[0]
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.