Package com.ibm.icu.text

Examples of com.ibm.icu.text.MessageFormat.format()


     */
    public void testSetLocaleLocale() {
        MessageFormat mf = new MessageFormat(pattern, Locale.US);
        mf.setLocale(Locale.GERMANY);
        mf.applyPattern(pattern);
        assertEquals(germanTarget, mf.format(args));
    }

    /*
     * Test method for 'com.ibm.icu.text.MessageFormat.setLocale(ULocale)'
     */
 
View Full Code Here


     */
    public void testSetLocaleULocale() {
        MessageFormat mf = new MessageFormat(pattern, Locale.US);
        mf.setLocale(ULocale.GERMANY);
        mf.applyPattern(pattern);
        assertEquals(germanTarget, mf.format(args));
    }

    /*
     * Test method for 'com.ibm.icu.text.MessageFormat.getLocale()'
     */
 
View Full Code Here

     * Test method for 'com.ibm.icu.text.MessageFormat.applyPattern(String)'
     */
    public void testApplyPattern() {
        MessageFormat mf = new MessageFormat("foo");
        mf.applyPattern(pattern);
        assertEquals(englishTarget, mf.format(args));
    }

    /*
     * Test method for 'com.ibm.icu.text.MessageFormat.toPattern()'
     */
 
View Full Code Here

            NumberFormat.getIntegerInstance(),
            DateFormat.getTimeInstance(DateFormat.SHORT),
            DateFormat.getDateInstance(),
        };
        mf.setFormats(formats);
        assertEquals(englishTarget, mf.format(args));
   }

    /*
     * Test method for 'com.ibm.icu.text.MessageFormat.setFormatByArgumentIndex(int, Format)'
     public void testSetFormatByArgumentIndex() {
View Full Code Here

     */
    public void testSetFormat() {
        // and ok again       
        MessageFormat mf = new MessageFormat(pattern, Locale.US);
        mf.setFormat(1, DateFormat.getTimeInstance(DateFormat.LONG));
        assertEquals(modifiedTarget, mf.format(args));
    }

    /*
     * Test method for 'com.ibm.icu.text.MessageFormat.getFormatsByArgumentIndex()'
    public void testGetFormatsByArgumentIndex() {
View Full Code Here

     */
    public void testFormatObjectArrayStringBufferFieldPosition() {
        MessageFormat mf = new MessageFormat(pattern, Locale.US);
        StringBuffer buf = new StringBuffer();
        FieldPosition fp = new FieldPosition(0);
        mf.format(args, buf, fp);
        assertEquals(englishTarget, buf.toString());
    }

    /*
     * Test method for 'com.ibm.icu.text.MessageFormat.format(String, Object[])'
View Full Code Here

     */
    public void testFormatObjectStringBufferFieldPosition() {
        MessageFormat mf = new MessageFormat(pattern, Locale.US);
        StringBuffer buf = new StringBuffer();
        FieldPosition fp = new FieldPosition(0);
        mf.format((Object)args, buf, fp);
        assertEquals(englishTarget, buf.toString());
    }

    /*
     * Test method for 'com.ibm.icu.text.MessageFormat.parse(String, ParsePosition)'
View Full Code Here

     */
    public void testAutoQuoteApostrophe() {
        String str = "Let's meet at {1,time,h 'o'' clock'} at l'Orange Bleue";
        String pat = MessageFormat.autoQuoteApostrophe(str);
        MessageFormat mf = new MessageFormat(pat, Locale.US);
        String result = mf.format(args);
        assertEquals("Let's meet at 8 o' clock at l'Orange Bleue", result);
        assertEquals("Let''s meet at {1,time,h 'o'' clock'} at l''Orange Bleue", pat);
    }

    /*
 
View Full Code Here

            String regPat = getTZLocalizationInfo(locale, REGION_FORMAT);
            if (regPat == null) {
                regPat = DEF_REGION_FORMAT;
            }
            MessageFormat mf = new MessageFormat(regPat);
            return mf.format(new Object[] { country });
        }

        if (city == null) {
            city = tzid.substring(tzid.lastIndexOf('/')+1).replace('_',' ');
        }
View Full Code Here

        if (flbPat == null) {
            flbPat = DEF_FALLBACK_FORMAT;
        }
        MessageFormat mf = new MessageFormat(flbPat);

        return mf.format(new Object[] { city, country });
    }

    private static final String DEF_REGION_FORMAT = "{0}";
    private static final String DEF_FALLBACK_FORMAT = "{1} ({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.