### Question:
XpathUtils { public static Date asDate(String expression, Node node) throws XPathExpressionException { String dateString = evaluateAsString(expression, node); if (isEmptyString(dateString)) return null; return DateUtils.parseISO8601Date(dateString); }  static Document documentFrom(InputStream is); static Document documentFrom(String xml); static Document documentFrom(URL url); static Double asDouble(String expression, Node node); static String asString(String expression, Node node); static Integer asInteger(String expression, Node node); static Boolean asBoolean(String expression, Node node); static Float asFloat(String expression, Node node); static Long asLong(String expression, Node node); static Byte asByte(String expression, Node node); static Date asDate(String expression, Node node); static ByteBuffer asByteBuffer(String expression, Node node); static boolean isEmpty(Node node); static int nodeLength(NodeList list); static Node asNode(String nodeName, Node node); static XPath xpath();  }### Answer:
@Test public void testAsDate() throws Exception { Calendar expectedDate = new GregorianCalendar(); expectedDate.set(Calendar.YEAR, 2008); expectedDate.set(Calendar.MONTH, Calendar.OCTOBER); expectedDate.set(Calendar.DAY_OF_MONTH, 7); expectedDate.set(Calendar.AM_PM, Calendar.AM); expectedDate.set(Calendar.HOUR, 11); expectedDate.set(Calendar.MINUTE, 51); expectedDate.set(Calendar.SECOND, 50); expectedDate.set(Calendar.MILLISECOND, 0); expectedDate.setTimeZone(new SimpleTimeZone(0, "UTC")); Document document = XpathUtils.documentFrom(DOCUMENT); Date date = XpathUtils.asDate("Foo/Since", document); assertNotNull(date); assertEquals(expectedDate.getTimeInMillis(), date.getTime()); assertNull(XpathUtils.asDate("Foo/Empty", document)); }
@Test public void testAsDate() throws Exception { Calendar expectedDate = new GregorianCalendar(); expectedDate.set(Calendar.YEAR, 2008); expectedDate.set(Calendar.MONTH, Calendar.OCTOBER); expectedDate.set(Calendar.DAY_OF_MONTH, 7); expectedDate.set(Calendar.AM_PM, Calendar.AM); expectedDate.set(Calendar.HOUR, 11); expectedDate.set(Calendar.MINUTE, 51); expectedDate.set(Calendar.SECOND, 50); expectedDate.set(Calendar.MILLISECOND, 0); expectedDate.setTimeZone(new SimpleTimeZone(0, "UTC")); Document document = XpathUtils.documentFrom(DOCUMENT); Date date = XpathUtils.asDate("Foo/Since", document); assertNotNull(date); assertEquals(expectedDate.getTimeInMillis(), date.getTime()); assertEquals(null, XpathUtils.asDate("Foo/Empty", document)); }