Package java.text

Examples of java.text.MessageFormat.toPattern()


            emf = new ExtendedMessageFormat(pattern);
        } else {
            emf = new ExtendedMessageFormat(pattern, locale);
        }
        assertEquals("format "    + buffer.toString(), mf.format(args), emf.format(args));
        assertPatternsEqual("toPattern " + buffer.toString(), mf.toPattern(),  emf.toPattern());
    }

    //can't trust what MessageFormat does with toPattern() pre 1.4:
    private void assertPatternsEqual(String message, String expected, String actual) {
        if (SystemUtils.isJavaVersionAtLeast(1.4f)) {
View Full Code Here


            }
            MessageFormat mf = new MessageFormat("{0,number," + format + "}");
            if (loc != null)
            {
               mf.setLocale(loc);
               mf.applyPattern(mf.toPattern());
            }

            return mf.format(new Object[]
            { value });
         }
View Full Code Here

            }
            MessageFormat mf = new MessageFormat("{0,date," + format + "}");
            if (loc != null)
            {
               mf.setLocale(loc);
               mf.applyPattern(mf.toPattern());
            }
            return mf.format(new Object[]
            { value });
         }
         else if (value instanceof Calendar)
View Full Code Here

            MessageFormat mf = new MessageFormat("{0,date," + format + "}");
            if (loc != null)
            {
               mf.setLocale(loc);
               mf.applyPattern(mf.toPattern());
            }
            return mf.format(new Object[]
            { value });
         }
         else
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

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.