Java BigDecimal.valueOf(long unscaledVal, int scale)
Syntax
BigDecimal.valueOf(long unscaledVal, int scale) has the following syntax.
public static BigDecimal valueOf(long unscaledVal, int scale)
Example
In the following code shows how to use BigDecimal.valueOf(long unscaledVal, int scale) method.
/*from w w w . ja v a 2s . c o m*/
import java.math.BigDecimal;
public class Main {
public static void main(String[] args) {
Long l = new Long("12345678");
// assign the bigdecimal value of l to bg scale is 4
BigDecimal bg = BigDecimal.valueOf(l, 4);
System.out.println( bg );
}
}
The code above generates the following result.