Package com.ibm.icu.text

Examples of com.ibm.icu.text.MessageFormat


    private static int totalLanguage;
    private static String what;
   
    public void updateScriptAndLanguages(){
        openScriptAndLanguages(ScriptAndLanguages);
        MessageFormat format = new MessageFormat(moduleHeader);
        Object args[] = {new Date(System.currentTimeMillis())};

        System.out.print("Updating file "+ScriptAndLanguages);
       
        updateFile.print(format.format(args));
        updateFile.println(ICUVersion);
        updateFile.println("Total Script="+totalScript);
        updateFile.println("Total Language="+totalLanguage);
        updateFile.println("Scripts={");
        for(int i=0;i<scriptVersionNumber.size();i++){
View Full Code Here


     *
     * @param args - the command line arugments
     */
    public static void main(String[] args)
    {
        MessageFormat fmt = new MessageFormat("{0}L, {1}L, {2}L, {3}L");       
        BigDecimal universalMin = new BigDecimal(Long.MIN_VALUE);
        BigDecimal universalMax = new BigDecimal(Long.MAX_VALUE);
        Object limitArgs[] = {null, null, null, null};
       
        System.out.println("\nTo, From limits:");
       
        // from limits
        for(int scale = 0; scale < UniversalTimeScale.MAX_SCALE; scale += 1) {
            BigDecimal min = UniversalTimeScale.toBigDecimalTrunc(universalMin, scale).max(universalMin);
            BigDecimal max = UniversalTimeScale.toBigDecimalTrunc(universalMax, scale).min(universalMax);
            long minLong   = min.longValue();
            long maxLong   = max.longValue();
           
            limitArgs[2] = min.toString();
            limitArgs[3] = max.toString();

            // to limits
            BigDecimal minTrunc   = UniversalTimeScale.bigDecimalFrom(min, scale);
            BigDecimal maxTrunc   = UniversalTimeScale.bigDecimalFrom(max, scale);
            BigDecimal minResidue = minTrunc.subtract(universalMin);
            BigDecimal maxResidue = universalMax.subtract(maxTrunc);
            long units            = UniversalTimeScale.getTimeScaleValue(scale, UniversalTimeScale.UNITS_VALUE);
            BigDecimal half       = new BigDecimal(units == 1? 0: units / 2 - 1);
           
            min = minTrunc.subtract(minResidue.min(half));
            max = maxTrunc.add(maxResidue.min(half));
            limitArgs[0] = min.toString();
            limitArgs[1] = max.toString();
           
            System.out.println(fmt.format(limitArgs));
           
            // round-trip test the from limits
            if(UniversalTimeScale.toLong(UniversalTimeScale.from(minLong, scale), scale) != minLong) {
                System.out.println("OOPS: min didn't round trip!");
            }
View Full Code Here

        // more than 719164 days before 1970.
        long before0001AD = -1000000 * javaDays;
        GregorianCalendar cal = new GregorianCalendar(utc, Locale.ENGLISH);
        cal.setGregorianChange(new Date(before0001AD));

        MessageFormat fmt = new MessageFormat("{0, date, full} {0, time, full} = {1}");
        Object arguments[] = {cal, null};
       
        System.out.println("Epoch offsets:");
       
        // January 1, 0001 00:00:00 is the universal epoch date...
        cal.set(1, Calendar.JANUARY, 1, 0, 0, 0);

        long universalEpoch = cal.getTimeInMillis();
       
        for (int i = 0; i < epochDates.length; i += 1) {
            int[] date = epochDates[i];
           
            cal.set(date[0], date[1], date[2]);
           
            long millis = cal.getTimeInMillis();
           
            arguments[1] = Long.toString((millis - universalEpoch) * milliseconds);
           
            System.out.println(fmt.format(arguments));
         }
    }
View Full Code Here

     *
     * @see com.ibm.icu.util.UniversalTimeScale
     */
    public static void main(String[] args)
    {
        MessageFormat fmt = new MessageFormat("'{'{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}},");
        Object cargs[] = {null, null, null, null, null, null, null, null, null, null, null};
       
        System.out.println("\nC data:");
       
        for (int scale = 0; scale < UniversalTimeScale.MAX_SCALE; scale += 1) {
            long units = UniversalTimeScale.getTimeScaleValue(scale, UniversalTimeScale.UNITS_VALUE);
           
            if (units == ticks) {
                cargs[0] = "ticks";
            } else if (units == microseconds) {
                cargs[0] = "microseconds";
            } else if (units == milliseconds) {
                cargs[0] = "milliseconds";
            } else if (units == seconds) {
                cargs[0] = "seconds";
            } else if (units == minutes) {
                cargs[0] = "minutes";
            } else if (units == hours) {
                cargs[0] = "hours";
            } else if (units == days) {
                cargs[0] = "days";
            } else {
                cargs[0] = "INT64_C(" + Long.toString(units) + ")";
            }
           
            cargs[1= minMaxFilter(UniversalTimeScale.getTimeScaleValue(scale, UniversalTimeScale.EPOCH_OFFSET_VALUE));
            cargs[2= minMaxFilter(UniversalTimeScale.getTimeScaleValue(scale, UniversalTimeScale.FROM_MIN_VALUE));
            cargs[3= minMaxFilter(UniversalTimeScale.getTimeScaleValue(scale, UniversalTimeScale.FROM_MAX_VALUE));
            cargs[4= minMaxFilter(UniversalTimeScale.getTimeScaleValue(scale, UniversalTimeScale.TO_MIN_VALUE));
            cargs[5= minMaxFilter(UniversalTimeScale.getTimeScaleValue(scale, UniversalTimeScale.TO_MAX_VALUE));
            cargs[6= minMaxFilter(UniversalTimeScale.getTimeScaleValue(scale, UniversalTimeScale.EPOCH_OFFSET_PLUS_1_VALUE));
            cargs[7= minMaxFilter(UniversalTimeScale.getTimeScaleValue(scale, UniversalTimeScale.EPOCH_OFFSET_MINUS_1_VALUE));
            cargs[8= minMaxFilter(UniversalTimeScale.getTimeScaleValue(scale, UniversalTimeScale.UNITS_ROUND_VALUE));
            cargs[9= minMaxFilter(UniversalTimeScale.getTimeScaleValue(scale, UniversalTimeScale.MIN_ROUND_VALUE));
            cargs[10] = minMaxFilter(UniversalTimeScale.getTimeScaleValue(scale, UniversalTimeScale.MAX_ROUND_VALUE));
           
            System.out.println(fmt.format(cargs));
        }
    }
View Full Code Here

        if (getSingleCountry(tzid) != null) { // single country
            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('_',' ');
        }

        String flbPat = getTZLocalizationInfo(locale, FALLBACK_FORMAT);
        if (flbPat == null) {
            flbPat = DEF_FALLBACK_FORMAT;
        }
        MessageFormat mf = new MessageFormat(flbPat);

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

        writeHeader(define, includeFiles, null);
    }
   
    public void writeHeader(String define, String[] includeFiles, String brief)
    {
        MessageFormat format = new MessageFormat(moduleHeader);
        Object args[] = {new Date(System.currentTimeMillis())};

        output.print(format.format(args));
       
        if (define != null) {
            wroteDefine = true;
            output.print("#ifndef ");
            output.println(define);
View Full Code Here

                pattern = patterns[glueIndex];
            }
        } catch (MissingResourceException e) {
            // use default
        }
        fCombinedFormat = new MessageFormat(pattern, locale);
        return fCombinedFormat;
    }
View Full Code Here

   
    public static class MessageFormatHandler implements SerializableTest.Handler
    {
        public Object[] getTestObjects()
        {
            MessageFormat formats[] = {new MessageFormat("pattern{0}")};
           
            return formats;
        }
View Full Code Here

            return formats;
        }

        public boolean hasSameBehavior(Object a, Object b)
        {
            MessageFormat mfa = (MessageFormat) a;
            MessageFormat mfb = (MessageFormat) b;
            Object arguments[] = {new Integer(123456)};
           
            return mfa.format(arguments) != mfb.format(arguments);
        }
View Full Code Here

    {
        // {sfb} use double format in pattern, so result will match (not strictly necessary)
        final String pattern = "There {0,choice,0.0#are no files|1.0#is one file|1.0<are {0, number} files} on disk {1}. ";
        logln("The input pattern : " + pattern);
        try {
            MessageFormat fmt = new MessageFormat(pattern);
            assertEquals("toPattern", pattern, fmt.toPattern());
        } catch (IllegalArgumentException e) {
            errln("MessageFormat pattern creation failed.");
        }
    }
View Full Code Here

TOP

Related Classes of com.ibm.icu.text.MessageFormat

Copyright © 2018 www.massapicom. 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.