This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • BigDecimalConverter
Skip to end of metadata
Go to start of metadata
 import wicket.util.convert.converters.AbstractConverter;
 import wicket.util.convert.ConversionException;
 
 import java.util.Locale;
 import java.math.BigDecimal;
 
 /**
 * Converts Strings to/from BigDecimal representations. 
 *
 * @author Nick Heudecker
 */
 public class BigDecimalConverter extends AbstractConverter {
 
    protected Class getTargetType() {
        return BigDecimal.class;
    }
 
    public Object convert(Object o, Locale locale) {
        if (o == null) {
            return null;
        }
        else if (o instanceof BigDecimal) {
            BigDecimal bd = (BigDecimal) o;
            return bd;
        }
        else if (o instanceof String) {
            String s = (String) o;
            if (s.length() > 0) {
                return new BigDecimal((String) o);
            }
            else {
                return null;
            }
        }
        else {
            throw new ConversionException("Can't convert " +
                o.getClass().getName() + "["+o+"] to BigDecimal.");
        }
    }
 }
  • No labels