Java Number Convert numToInt(Number n)

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

Description

Converts a Number object into an Integer.

License

Creative Commons License

Parameter

Parameter Description
n Number to convert

Return

Integer representation of n

Declaration

public static Integer numToInt(Number n) 

Method Source Code

//package com.java2s;
//License from project: Creative Commons License 

public class Main {
    /**//from www.j  a  v a2 s . co  m
     * Converts a Number object into an Integer. Takes a cast and method call.
     * This provides a simple wrapper.
     * @param n   Number to convert
     * @return   Integer representation of n
     */
    public static Integer numToInt(Number n) {
        return (Integer) (n.intValue());
    }

    /**
     * Wrapper for {@link Utils.numToInt(Number)}.
     * @param o
     * @return
     * @see Utils.numToInt(Number)
     */
    public static Integer numToInt(Object o) {
        if (o instanceof Number) {
            return numToInt((Number) o);
        }
        return null;
    }
}

Related

  1. convertToMoney(float money)
  2. getMoneyConversion(int money, int divisor)
  3. numToBytes(byte[] buffer, long value)
  4. numToBytes(byte[] buffer, long value, int radix)
  5. numToBytes(long value, byte[] b, int off, int len)
  6. numToIPv4(StringBuilder host)
  7. numToLetter(String input)
  8. numToPowerOf(int num, int toPowerOf)
  9. numToStringWithOrder(long count)