@Test public void convert2Double(){ System.out.println("START: convert2Double"); Assert.assertEquals(6.0d,LibConvertNumberUtils.convert2Double(i,0)); Assert.assertEquals(8.0d,LibConvertNumberUtils.convert2Double(l,0)); Assert.assertEquals(3.12d,LibConvertNumberUtils.convert2Double(f,0)); Assert.assertEquals(9.9998d,LibConvertNumberUtils.convert2Double(d,0)); Assert.assertEquals(0.00d,LibConvertNumberUtils.convert2Double(s1,0)); Assert.assertEquals(10.0d,LibConvertNumberUtils.convert2Double(s2,0)); Assert.assertEquals(11.11d,LibConvertNumberUtils.convert2Double(s3,0)); Assert.assertEquals(20.01d,LibConvertNumberUtils.convert2Double(s4,0)); Assert.assertEquals(30.3366d,LibConvertNumberUtils.convert2Double(s5,0)); Assert.assertEquals(0.00d,LibConvertNumberUtils.convert2Double(s6,0)); System.out.println("END: convert2Double"); }
public final static double convert2Double(Object value, double defaultValue) { if (value == null || "".equals(value.toString().trim())) { return defaultValue; } try { return Double.valueOf(value.toString()); } catch (Exception e) { return defaultValue; } }
LibConvertNumberUtils { public final static double convert2Double(Object value, double defaultValue) { if (value == null || "".equals(value.toString().trim())) { return defaultValue; } try { return Double.valueOf(value.toString()); } catch (Exception e) { return defaultValue; } } }
LibConvertNumberUtils { public final static double convert2Double(Object value, double defaultValue) { if (value == null || "".equals(value.toString().trim())) { return defaultValue; } try { return Double.valueOf(value.toString()); } catch (Exception e) { return defaultValue; } }  }
LibConvertNumberUtils { public final static double convert2Double(Object value, double defaultValue) { if (value == null || "".equals(value.toString().trim())) { return defaultValue; } try { return Double.valueOf(value.toString()); } catch (Exception e) { return defaultValue; } }  final static int convert2Int(Object value, int defaultValue); final static double convert2Double(Object value, double defaultValue); final static long convert2Long(Object value, long defaultValue); }
LibConvertNumberUtils { public final static double convert2Double(Object value, double defaultValue) { if (value == null || "".equals(value.toString().trim())) { return defaultValue; } try { return Double.valueOf(value.toString()); } catch (Exception e) { return defaultValue; } }  final static int convert2Int(Object value, int defaultValue); final static double convert2Double(Object value, double defaultValue); final static long convert2Long(Object value, long defaultValue);  }