1 11 12 package org.eclipse.core.internal.databinding.conversion; 13 14 import java.math.BigDecimal ; 15 import java.math.BigInteger ; 16 17 import com.ibm.icu.text.NumberFormat; 18 19 27 public class NumberToBigIntegerConverter extends NumberToNumberConverter { 28 32 public NumberToBigIntegerConverter(NumberFormat numberFormat, Class fromType) { 33 super(numberFormat, fromType, BigInteger .class); 34 } 35 36 39 protected Number doConvert(Number number) { 40 return toBigDecimal(number).toBigInteger(); 41 } 42 43 private static BigDecimal toBigDecimal(Number number) { 44 if (number instanceof BigDecimal ) { 45 return (BigDecimal ) number; 46 } 47 48 return new BigDecimal (number.doubleValue()); 49 } 50 } 51 | Popular Tags |