Parse object to decimal - Android java.lang

Android examples for java.lang:Double

Description

Parse object to decimal

Demo Code

import android.annotation.SuppressLint;
import java.text.SimpleDateFormat;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static boolean decimal(Object o) {
        double n = 0;
        try {//from   ww w .  ja  v a2  s . c  o  m
            n = Double.parseDouble(o.toString().trim());
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        if (n > 0.0) {
            return true;
        } else {
            return false;
        }
    }

}

Related Tutorials