commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r541100 - /jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/NumberConverter.java
Date Wed, 23 May 2007 22:11:29 GMT
Author: niallp
Date: Wed May 23 15:11:28 2007
New Revision: 541100

URL: http://svn.apache.org/viewvc?view=rev&rev=541100
Log:
Improve BigInteger / BigDecimal conversion handling

Modified:
    jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/NumberConverter.java

Modified: jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/NumberConverter.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/NumberConverter.java?view=diff&rev=541100&r1=541099&r2=541100
==============================================================================
--- jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/NumberConverter.java
(original)
+++ jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/NumberConverter.java
Wed May 23 15:11:28 2007
@@ -363,6 +363,8 @@
         if (type.equals(BigDecimal.class)) {
             if (value instanceof Float || value instanceof Double) {
                 return new BigDecimal(value.toString());
+            } else if (value instanceof BigInteger) {
+                return new BigDecimal((BigInteger)value);
             } else {
                 return BigDecimal.valueOf(value.longValue());
             }
@@ -370,7 +372,11 @@
 
         // BigInteger
         if (type.equals(BigInteger.class)) {
-            return BigInteger.valueOf(value.longValue());
+            if (value instanceof BigDecimal) {
+                return ((BigDecimal)value).toBigInteger();
+            } else {
+                return BigInteger.valueOf(value.longValue());
+            }
         }
 
         String msg = toString(getClass()) + " cannot handle conversion to '"



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message