Package java.text

Examples of java.text.DecimalFormat.applyLocalizedPattern()


            symbols = new DecimalFormatSymbols(locale);
        }
       
        DecimalFormat format = (DecimalFormat) NumberFormat.getInstance();
        format.setDecimalFormatSymbols(symbols);
        format.applyLocalizedPattern(pattern);
        return format.format(number);
    }

    private void assertArgCount(int count) {
        if (getArgumentCount() != count) {
View Full Code Here


        // if some constructors default pattern to null, it makes only sense
        // to handle null pattern gracefully
        if (pattern != null) {
            if (locPattern) {
                formatter.applyLocalizedPattern(pattern);
            } else {
                formatter.applyPattern(pattern);
            }
        } else {
            log.debug("No pattern provided, using default.");
View Full Code Here

        DecimalFormat numberFormat = (DecimalFormat) NumberFormat.getInstance(locale);

        // if some constructors default pattern to null, it makes only sense to handle null pattern gracefully
        if (pattern != null) {
            if (locPattern) {
                numberFormat.applyLocalizedPattern(pattern);
            } else {
                numberFormat.applyPattern(pattern);
            }
        } else {
            log.debug("No pattern provided, using default.");
View Full Code Here

    // try null argument
    boolean pass = false;
    try
    {
      f1.applyLocalizedPattern(null);
    }
    catch (NullPointerException e)
    {
      pass = true;  
    }
View Full Code Here

   
    // try illegal pattern
    pass = false;
    try
    {
      f1.applyLocalizedPattern(";;");
    }
    catch (IllegalArgumentException e)
    {
      pass = true;  
    }
View Full Code Here

            }
           
                // create one if cache missed, set the pattern
            fmt = (DecimalFormat)NumberFormat.getNumberInstance(locale);
            if (!StringUtil.nullOrEmptyString(pattern)) {
                fmt.applyLocalizedPattern(pattern);
            }
           
                // cache it & return
            cache.put(locale, pattern, fmt);
            return fmt;
View Full Code Here

    protected Format instantiateFormat (int type, Locale locale, String pattern)
    {
        pattern = (pattern == null) ? "" : pattern;
        DecimalFormat fmt = (DecimalFormat)NumberFormat.getNumberInstance(locale);
        if (!StringUtil.nullOrEmptyString(pattern)) {
            fmt.applyLocalizedPattern(pattern);
        }
        fmt.setGroupingUsed(true);
        return fmt;
    }
View Full Code Here

    protected Format instantiateFormat (int type, Locale locale, String pattern)
    {
        pattern = (pattern == null) ? "" : pattern;
        DecimalFormat fmt = (DecimalFormat)NumberFormat.getNumberInstance(locale);
        if (!StringUtil.nullOrEmptyString(pattern)) {
            fmt.applyLocalizedPattern(pattern);
        }

        // set this to false so we can detect fractional values and throw exception
        // see parseInt()
        fmt.setParseIntegerOnly(false);
View Full Code Here

    public void setElementPattern(final String pattern, final boolean localized) {
        final Format format = elementFormat;
        if (format instanceof DecimalFormat) {
            final DecimalFormat df = (DecimalFormat) format;
            if (localized) {
                df.applyLocalizedPattern(pattern);
            } else {
                df.applyPattern(pattern);
            }
        } else if (format instanceof SimpleDateFormat) {
            final SimpleDateFormat df = (SimpleDateFormat) format;
View Full Code Here

                df.applyPattern(pattern);
            }
        } else if (format instanceof SimpleDateFormat) {
            final SimpleDateFormat df = (SimpleDateFormat) format;
            if (localized) {
                df.applyLocalizedPattern(pattern);
            } else {
                df.applyPattern(pattern);
            }
        } else if (format instanceof AngleFormat) {
            ((AngleFormat) format).applyPattern(pattern);
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.