@Test public void optDouble() { System.out.println("-----optDouble test-----"); System.out.println(NumberUtil.optDouble(null, 0)); System.out.println(NumberUtil.optDouble("", 1)); System.out.println(NumberUtil.optDouble("null", 2)); System.out.println(NumberUtil.optDouble("123", 3)); System.out.println(NumberUtil.optDouble("123.6", 4)); System.out.println(NumberUtil.optDouble("123.6.6.6", 5)); }
public static double optDouble(String numStr, double def) { if (numStr == null || numStr.isEmpty()) { return def; } try { return Double.parseDouble(numStr); } catch (Exception e) { return def; } }
NumberUtil { public static double optDouble(String numStr, double def) { if (numStr == null || numStr.isEmpty()) { return def; } try { return Double.parseDouble(numStr); } catch (Exception e) { return def; } } }
NumberUtil { public static double optDouble(String numStr, double def) { if (numStr == null || numStr.isEmpty()) { return def; } try { return Double.parseDouble(numStr); } catch (Exception e) { return def; } }  }
NumberUtil { public static double optDouble(String numStr, double def) { if (numStr == null || numStr.isEmpty()) { return def; } try { return Double.parseDouble(numStr); } catch (Exception e) { return def; } }  static int optInt(String numStr, int def); static long optLong(String numStr, long def); static float optFloat(String numStr, float def); static double optDouble(String numStr, double def); static String getWanUnitString(double num , String unit); static String getThousandSeparatorFormat(double num); }
NumberUtil { public static double optDouble(String numStr, double def) { if (numStr == null || numStr.isEmpty()) { return def; } try { return Double.parseDouble(numStr); } catch (Exception e) { return def; } }  static int optInt(String numStr, int def); static long optLong(String numStr, long def); static float optFloat(String numStr, float def); static double optDouble(String numStr, double def); static String getWanUnitString(double num , String unit); static String getThousandSeparatorFormat(double num);  }