ParseUtils { public static double parseStringAsDouble(String in) throws IndexParseFieldException { try { return Double.parseDouble(in); } catch (NumberFormatException e) { throw new IndexParseFieldException(in, e); } }  static ByteBuffer parseBase64StringAsByteBuffer(String in); static boolean parseStringAsBoolean(String in); static Date parseStringAsDate(String in); static double parseStringAsDouble(String in); static int parseStringAsInt(String in); static UUID parseStringAsUUID(String in); static Long parseStringAsLong(String in);  }
@Test public void testParseStringAsDouble() throws Exception { System.out.println("parseStringAsDouble"); String in = "0"; double expResult = 0.0; double result = ParseUtils.parseStringAsDouble(in); assertEquals(expResult, result, 0.0); in = "1.123456"; expResult = 1.123456; result = ParseUtils.parseStringAsDouble(in); assertEquals(expResult, result, 0.0); in = "-1.123456"; expResult = -1.123456; result = ParseUtils.parseStringAsDouble(in); assertEquals(expResult, result, 0.0); boolean expectExceptionThrown = false; try { ParseUtils.parseStringAsDouble("dafhfda"); } catch (IndexParseFieldException e) { expectExceptionThrown = true; assertNotNull(e.getCause()); assertNotNull(e.getMessage()); } assertTrue(expectExceptionThrown); }