parse value to long - Android java.lang

Android examples for java.lang:String Parse

Description

parse value to long

Demo Code


//package com.java2s;
import android.text.TextUtils;

public class Main {
    /**//from www.  j av a  2s .  c om
     * parse value to long
     */
    public static long toLong(Object value) {
        if (value instanceof Number) {
            return ((Number) value).longValue();
        }
        return value == null ? 0 : toLong(String.valueOf(value));
    }

    /**
     * parse value to long
     */
    public static long toLong(String value) {
        return TextUtils.isEmpty(value) ? 0 : Long.parseLong(value);
    }
}

Related Tutorials