Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import android.text.TextUtils;

public class Main {
    /**
     * parse value to short
     */
    public static short toShort(Object value) {
        if (value instanceof Number) {
            return ((Number) value).shortValue();
        }
        return value == null ? 0 : toShort(String.valueOf(value));
    }

    /**
     * parse value to short
     */
    public static short toShort(String value) {
        return TextUtils.isEmpty(value) ? 0 : Short.parseShort(value);
    }
}