BigDecimal to Long - Java java.math

Java examples for java.math:BigDecimal Convert

Description

BigDecimal to Long

Demo Code


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

public class Main {
    public static void main(String[] argv) throws Exception {
        Object obj = "java2s.com";
        System.out.println(BigDecimal2Long(obj));
    }// w  w  w  .  j av  a 2 s .c  o m

    public static Long BigDecimal2Long(Object obj) {
        if (obj == null) {
            return 0l;
        }
        BigDecimal bd = (BigDecimal) obj;
        return bd.longValue();
    }
}

Related Tutorials