Java Number to Long numberToLong(Number n)

Here you can find the source of numberToLong(Number n)

Description

number To Long

License

Apache License

Declaration

public static Long numberToLong(Number n) 

Method Source Code

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

public class Main {
    public static Long numberToLong(Number n) {
        if (n != null && !(n instanceof Float)) {
            if (n instanceof Integer)
                return ((Integer) n).longValue();
            else if (n instanceof Short)
                return ((Short) n).longValue();
            else if (n instanceof Long)
                return ((Long) n).longValue();
        }//  ww  w  .j ava  2 s.  com
        return null;
    }
}

Related

  1. NumberToLong(final Number value)