Java Short Number Create toShort(Object obj)

Here you can find the source of toShort(Object obj)

Description

to Short

License

Open Source License

Declaration

public static Short toShort(Object obj) 

Method Source Code

//package com.java2s;
/*/*from  ww  w .  j  a va 2s  .c o  m*/
 * Este programa es software libre; usted puede redistribuirlo y/o modificarlo bajo los terminos
 * de la licencia "GNU General Public License" publicada por la Fundacion "Free Software Foundation".
 * Este programa se distribuye con la esperanza de que pueda ser util, pero SIN NINGUNA GARANTIA;
 * vea la licencia "GNU General Public License" para obtener mas informacion.
 */

public class Main {
    public static Short toShort(Object obj) {
        return obj == null ? null : obj instanceof Short ? (Short) obj : newShort(obj);
    }

    public static Short newShort(Object obj) {
        if (obj == null) {
            return null;
        } else if (obj instanceof Short) {
            Short pdq = (Short) obj;
            return pdq;
        } else if (obj instanceof String) {
            String pdq = (String) obj;
            return pdq.trim().isEmpty() ? null : new Short(pdq);
        } else {
            return new Short(obj.toString());
        }
    }
}

Related

  1. toShort(Number value)
  2. toShort(Object o)
  3. toShort(Object ob, Short defaultShort)
  4. toShort(Object obj)
  5. toShort(Object obj)
  6. toShort(Object obj)
  7. toShort(Object prmIntObject)
  8. toShort(Object value)
  9. toShort(Object value)