Code example for BigDecimal

Methods: multiply

0
     * @param value the currency value 
     * @return the integer representation 
     */ 
    public static long ConvertCurrencyToInteger(BigDecimal value) {
        return value.longValue() * 100 +
            value.subtract(new BigDecimal(value.longValue())).multiply(new BigDecimal(100)).longValue();
    } 
 
    /** 
     * Convert an integer to currency (ie 534 -> 5.34, 1010 -> 10.10) 
     * 
     * @param value the currency value 
     * @return the integer representation 
     */ 
    public static BigDecimal ConvertIntegerToCurrency(long value) {
        BigDecimal temp = new BigDecimal(value);
        return temp.divide(new BigDecimal(100));
    } 
 
}