Java BigDecimal to convertToFen(BigDecimal num1)

Here you can find the source of convertToFen(BigDecimal num1)

Description

convert To Fen

License

Apache License

Declaration

public static Long convertToFen(BigDecimal num1) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.math.BigDecimal;

public class Main {
    public static final int STANDARD_ROUND_HALF = BigDecimal.ROUND_HALF_UP;
    public static final int STANDARD_SCALE = 2;
    /**//from w w w  .  ja va2 s  . co m
     * 0
     **/
    public static final BigDecimal ZERO = new BigDecimal("0");
    /**
     * 100
     **/
    public static final BigDecimal HUNDRED = new BigDecimal("100");

    public static Long convertToFen(BigDecimal num1) {
        if (null == num1) {
            return ZERO.longValue();
        }
        BigDecimal temp = multiply(num1, HUNDRED);
        return temp.longValue();
    }

    public static BigDecimal multiply(BigDecimal num1, BigDecimal num2) {
        if (null == num1 || null == num2) {
            return ZERO;
        }
        BigDecimal temp = num1.multiply(num2);
        return temp.setScale(STANDARD_SCALE, STANDARD_ROUND_HALF);
    }
}

Related

  1. convertToBigDecimal(Object sourceValue)
  2. convertToBigDecimal(String s)
  3. convertToBigDecimal(String val)
  4. convertToBigDecimal(String value)
  5. convertToBigDecimal(String value)
  6. decimalToBytes(BigDecimal v, byte[] result, final int offset, int length)
  7. decimalToString(BigDecimal value)
  8. toBeforeDecimalPointString(BigDecimal bigDecimal)
  9. toDouble(BigDecimal b, boolean allownull)