Package org.outerj.i18n

Examples of org.outerj.i18n.DecimalFormat


            return null;
        }
    }

    public Object convertFromStringLocalized(String value, Locale locale) {
        DecimalFormat numberFormat = I18nSupport.getInstance().getIntegerFormat(locale);
        // TODO numberFormat.applyPattern(...)
        try {
            return new Long(numberFormat.parse(value).longValue());
        } catch (ParseException e) {
            return null;
        }
    }
View Full Code Here


    public String convertToString(Object value) {
        return value.toString();
    }

    public String convertToStringLocalized(Object value, Locale locale) {
        DecimalFormat numberFormat = I18nSupport.getInstance().getIntegerFormat(locale);
        // TODO numberFormat.applyPattern(...)
        return numberFormat.format(value);
    }
View Full Code Here

    public FormattingIntegerConvertor() {
        super();
    }

    public Object convertFromString(String value, Locale locale, Convertor.FormatCache formatCache) {
        DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache);
        try {
            Number decimalValue = decimalFormat.parse(value);
            if (decimalValue instanceof Integer)
                return decimalValue;
            else
                return new Integer(decimalValue.intValue());
        } catch (ParseException e) {
View Full Code Here

    protected int getDefaultVariant() {
        return NUMBER;
    }

    public Object convertFromString(String value, Locale locale, Convertor.FormatCache formatCache) {
        DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache);
        try {
            Number decimalValue = decimalFormat.parse(value);
            if (decimalValue instanceof BigDecimal)
                ;
      else if (decimalValue instanceof Integer)
        decimalValue = new BigDecimal(decimalValue .intValue());
            else if (decimalValue instanceof Long)
View Full Code Here

            return null;
        }
    }

    public String convertToString(Object value, Locale locale, Convertor.FormatCache formatCache) {
        DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache);
        return decimalFormat.format(value);
    }
View Full Code Here

        DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache);
        return decimalFormat.format(value);
    }

    protected final DecimalFormat getDecimalFormat(Locale locale, Convertor.FormatCache formatCache) {
        DecimalFormat decimalFormat = null;
        if (formatCache != null)
            decimalFormat = (DecimalFormat)formatCache.get();
        if (decimalFormat == null) {
            decimalFormat = getDecimalFormat(locale);
            if (formatCache != null)
View Full Code Here

        }
        return decimalFormat;
    }

    private DecimalFormat getDecimalFormat(Locale locale) {
        DecimalFormat decimalFormat = null;

        switch (variant) {
            case INTEGER:
                decimalFormat = I18nSupport.getInstance().getIntegerFormat(locale);
                break;
            case NUMBER:
                decimalFormat = I18nSupport.getInstance().getNumberFormat(locale);
                break;
            case CURRENCY:
                decimalFormat = I18nSupport.getInstance().getCurrencyFormat(locale);
                break;
            case PERCENT:
                decimalFormat = I18nSupport.getInstance().getPercentFormat(locale);
                break;
        }

        String pattern = (String)localizedPatterns.get(locale);

        if (pattern != null)
            decimalFormat.applyLocalizedPattern(pattern);
        else if (nonLocalizedPattern != null)
            decimalFormat.applyPattern(nonLocalizedPattern);

        return decimalFormat;
    }
View Full Code Here

    public FormattingLongConvertor() {
        super();
    }

    public Object convertFromString(String value, Locale locale, Convertor.FormatCache formatCache) {
        DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache);
        try {
            Number decimalValue = decimalFormat.parse(value);
            if (decimalValue instanceof Long)
                return decimalValue;
            else
                return new Long(decimalValue.longValue());
        } catch (ParseException e) {
View Full Code Here

    protected int getDefaultVariant() {
        return NUMBER;
    }

    public Object convertFromString(String value, Locale locale, Convertor.FormatCache formatCache) {
        DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache);
        try {
            Number decimalValue = decimalFormat.parse(value);
            if (decimalValue instanceof BigDecimal)
                ;
      else if (decimalValue instanceof Integer)
        decimalValue = new BigDecimal(decimalValue .intValue());
            else if (decimalValue instanceof Long)
View Full Code Here

            return null;
        }
    }

    public String convertToString(Object value, Locale locale, Convertor.FormatCache formatCache) {
        DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache);
        return decimalFormat.format(value);
    }
View Full Code Here

TOP

Related Classes of org.outerj.i18n.DecimalFormat

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.