Java Short Number Create toShort(Number num)

Here you can find the source of toShort(Number num)

Description

Convert the given number into a Short instance.

License

Open Source License

Parameter

Parameter Description
num A Number instance.

Return

A instance equivalent to the given number. null if num is null .

Declaration

public static Short toShort(Number num) 

Method Source Code

//package com.java2s;
/*//from ww  w .  j  av a  2  s  .  com
 * Copyright (c) 2015 NEC Corporation
 * All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this
 * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
 */

public class Main {
    /**
     * Convert the given number into a {@link Short} instance.
     *
     * @param num  A {@link Number} instance.
     * @return  A {@link Short} instance equivalent to the given number.
     *          {@code null} if {@code num} is {@code null}.
     */
    public static Short toShort(Number num) {
        return (num == null) ? null : Short.valueOf(num.shortValue());
    }
}

Related

  1. toShort(final String value)
  2. toShort(int src)
  3. toShort(int unsignedShort)
  4. toShort(long l)
  5. toShort(long n)
  6. toShort(Number value)
  7. toShort(Object o)
  8. toShort(Object ob, Short defaultShort)
  9. toShort(Object obj)