All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jidefx.utils.converter.IntegerConverter Maven / Gradle / Ivy

The newest version!
/*
 * @(#)IntegerConverter.java 5/19/2013
 *
 * Copyright 2002 - 2013 JIDE Software Inc. All rights reserved.
 */

package jidefx.utils.converter;

import java.text.DecimalFormat;
import java.text.NumberFormat;

/**
 * {@link ObjectConverter} implementation for {@link Integer}.
 */
public class IntegerConverter extends AbstractNumberConverter {

    public IntegerConverter() {
        this(DecimalFormat.getIntegerInstance());
    }

    public IntegerConverter(NumberFormat format) {
        super(format);
    }

    /**
     * Converts the String to a Integer. It will use the NumberFormat defined as {@link #PROPERTY_NUMBER_FORMAT} if any.
     * If not there, it will use {@link #getNumberFormat()} to get the NumberFormat to do the conversion.
     * 

* Please note, the conversion may involve rounding or truncation. * * @param string the string to be converted. * @param context the context * @return the Number converted from the String. */ @Override public Integer fromString(String string, ConverterContext context) { Number number = numberFromString(string, context); return number != null ? number.intValue() : null; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy