### Question:
DataTypeUtilities { public static double toDouble(Object o) { double value; if (o instanceof Number) { value = ((Number)o).doubleValue(); } else if (o instanceof Date) { value = ((Date)o).getTime(); } else if (o instanceof TimeSpan) { value = ((TimeSpan)o).getStart(); } else if (o instanceof String) { value = Double.parseDouble((String)o); } else { throw new IllegalArgumentException(o + " can't be converted to a double"); } return value; } private  DataTypeUtilities(); static boolean isNumeric(Object o); static boolean isNumeric(Class<?> c); static double toDouble(Object o); static Object fromDouble(double value, Class<?> theClass); static int compareTo(Object o1, Object o2); static String getLabel(Object o);  }### Answer:
@Test public void testToDouble() { assertEquals(1.2, DataTypeUtilities.toDouble(Double.valueOf(1.2)), 0.0000001); assertEquals(100, DataTypeUtilities.toDouble(new Date(100)), 0.0000001); assertEquals(0, DataTypeUtilities.toDouble("0"), 0.0000001); assertEquals(1.2, DataTypeUtilities.toDouble("1.2"), 0.0000001); try { DataTypeUtilities.toDouble("a"); fail("Should not be able to parse 'a'"); } catch (Exception e) { } }