Java Number Convert to numberToPrimitiveLong(Object o)

Here you can find the source of numberToPrimitiveLong(Object o)

Description

number To Primitive Long

License

Apache License

Declaration

public static long numberToPrimitiveLong(Object o) throws Exception 

Method Source Code

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

public class Main {
    public static long numberToPrimitiveLong(Object o) throws Exception {
        long i;/*from  www  . j a  v  a2s  .c  o m*/

        if (o instanceof Long)
            i = ((Long) o).longValue();
        else if (o instanceof Integer)
            i = ((Integer) o).longValue();
        else if (o instanceof Short)
            i = ((Short) o).longValue();
        else if (o instanceof Byte)
            i = ((Byte) o).longValue();
        else
            throw new Exception("Unknown integer type: " + o.getClass());

        return i;
    }
}

Related

  1. numberToFormattedString(Double d)
  2. numberToJson(Number number)
  3. numberToMinterm(int num, int length, int index, boolean[] output)
  4. numberToOrdinal(int i)
  5. numberToPaddedHexString(int number, int size)
  6. NumberToReal(Object n)