Package java.text

Examples of java.text.MessageFormat.applyPattern()


        MessageFormat format = new MessageFormat("{1,number,integer}");
        StringBuffer buffer = new StringBuffer();
        format.format(new Object[] { "0", new Double(53.863) }, buffer,
                new FieldPosition(0));
    assertEquals("Wrong result", "54", buffer.toString());
        format
                .applyPattern("{0,choice,0#zero|1#one '{1,choice,2#two {2,time}}'}");
        Date date = new Date();
        String expected = "one two "
                + DateFormat.getTimeInstance().format(date);
        String result = format.format(new Object[] { new Double(1.6),
View Full Code Here


        // Test for method void
        // java.text.MessageFormat.setLocale(java.util.Locale)
        MessageFormat format = new MessageFormat("date {0,date}");
        format.setLocale(Locale.CHINA);
        assertEquals("Wrong locale1", Locale.CHINA, format.getLocale());
        format.applyPattern("{1,date}");
        assertEquals("Wrong locale3", DateFormat.getDateInstance(DateFormat.DEFAULT,
                Locale.CHINA), format.getFormats()[0]);
    }

    /**
 
View Full Code Here

        MessageFormatKey key = new MessageFormatKey(pattern, locale);
        MessageFormat format = messageFormats.get(key);
        if (format == null) {
            format = new MessageFormat(pattern);
            format.setLocale(locale);
            format.applyPattern(pattern);
            messageFormats.put(key, format);
        }

        return format;
    }
View Full Code Here

        if (args != null) {
      MessageFormat formatter = new MessageFormat("");
      if (locCtxt.getLocale() != null) {
          formatter.setLocale(locCtxt.getLocale());
      }
      formatter.applyPattern(message);
      message = formatter.format(args);
        }
    } catch (MissingResourceException mre) {
    }
      }
View Full Code Here

                            //System.out.println("LOCALE: " + locale);
                            if (locale != null) {
                                formatter.setLocale(locale);
                            }
                        }
      formatter.applyPattern(message);
      message = formatter.format(messageArgs);
        }
    } catch (MissingResourceException mre) {
        message = UNDEFINED_KEY + key + UNDEFINED_KEY;
    }
View Full Code Here

        // regardless of what locale is later specified!
        // It appears that the problem does not exist in JDK 1.4.

        MessageFormat messageFormat = new MessageFormat("");
        messageFormat.setLocale(_locale);
        messageFormat.applyPattern(pattern);

        return messageFormat.format(args);
    }

    public String format(String key, Object arg0)
View Full Code Here

    private void computeAndDrawHalo( int nice, MapGraphicContext context, Unit measurement,
            BarStyle type, int x, int y, int width, int height, Color bgColor ) {

        // determine maximum label size
        MessageFormat formatter = new MessageFormat("", Locale.getDefault()); //$NON-NLS-1$
        formatter.applyPattern(NUMBER_PATTERN + measurement.display);
        Object[] arguments = {nice * type.getNumintervals()};
        String msg = formatter.format(arguments);
        Rectangle2D msgBounds = context.getGraphics().getStringBounds(msg);

        double textwidth = msgBounds.getWidth();
View Full Code Here

        if (font != null && font.getFont() != null) {
            graphics.setFont(font.getFont());
        }

        MessageFormat formatter = new MessageFormat("", Locale.getDefault()); //$NON-NLS-1$
        formatter.applyPattern(NUMBER_PATTERN + measurement.display);

        Object[] arguments = {nice};
        String msg = formatter.format(arguments);
        Rectangle2D msgBounds = graphics.getStringBounds(msg);
View Full Code Here

        if (font != null && font.getFont() != null) {
            graphics.setFont(font.getFont());
        }

        MessageFormat formatter = new MessageFormat("", Locale.getDefault()); //$NON-NLS-1$
        formatter.applyPattern(NUMBER_PATTERN);

        for( int i = -1; i < numIntervals - 1; i++ ) {

            drawIntervalLabel(nice, x, y, height, barWidth, width, numIntervals, c,
                    graphics, formatter, i);
View Full Code Here

            drawIntervalLabel(nice, x, y, height, barWidth, width, numIntervals, c,
                    graphics, formatter, i);
        }

        formatter = new MessageFormat("", Locale.getDefault()); //$NON-NLS-1$
        formatter.applyPattern(NUMBER_PATTERN + measurement.display);
        drawIntervalLabel(nice, x, y, height, barWidth, width, numIntervals, c,
                graphics, formatter, numIntervals - 1);
    }

    /**
 
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.