Convert an integer to currency (ie 534 -> 5.34, 1010 -> 10.10) - Android java.math

Android examples for java.math:BigDecimal

Description

Convert an integer to currency (ie 534 -> 5.34, 1010 -> 10.10)

Demo Code


//package com.java2s;
import java.math.BigDecimal;

public class Main {
    /**//from  w  w  w .  ja  va 2 s .  c om
     * 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));
    }
}

Related Tutorials