Java tutorial
//package com.java2s; //License from project: Apache License import android.text.TextUtils; public class Main { /** * parse value to double */ public static double toDouble(Object value) { if (value instanceof Number) { return ((Number) value).doubleValue(); } return value == null ? 0 : toDouble(String.valueOf(value)); } /** * parse value to double */ public static double toDouble(String value) { return TextUtils.isEmpty(value) ? 0 : Double.parseDouble(value); } }