DomUtils { public static Date getDate(final String text) { try { final DatatypeFactory datatypeFactory = DatatypeFactory.newInstance(); final XMLGregorianCalendar xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar(text); return xmlGregorianCalendar.toGregorianCalendar().getTime(); } catch (Exception e) { LOG.warn("Unable to parse '{}'", text); } return null; } private  DomUtils(); static void enableFeature(String feature); static void disableFeature(String feature); static boolean registerNamespace(final DSSNamespace namespace); static TransformerFactory getSecureTransformerFactory(); static Transformer getSecureTransformer(); static Document buildDOM(); static Document buildDOM(final String xmlString); static Document buildDOM(final byte[] bytes); static Document buildDOM(final DSSDocument dssDocument); static boolean isDOM(final byte[] bytes); static Document buildDOM(final InputStream inputStream); static void setAttributeNS(Element element, DSSNamespace namespace, DSSAttribute attribute, String value); static Element addElement(final Document document, final Element parentDom, final DSSNamespace namespace, final DSSElement element); static XPathExpression createXPathExpression(final String xpathString); static String getValue(final Node xmlNode, final String xPathString); static NodeList getNodeList(final Node xmlNode, final String xPathString); static Node getNode(final Node xmlNode, final String xPathString); static Element getElement(final Node xmlNode, final String xPathString); static boolean isNotEmpty(final Node xmlNode, final String xPathString); static Element addTextElement(final Document document, final Element parentDom, final DSSNamespace namespace, final DSSElement element, final String value); static void setTextNode(final Document document, final Element parentDom, final String text); static XMLGregorianCalendar createXMLGregorianCalendar(final Date date); static Date getDate(final String text); static List<String> getChildrenNames(final Node xmlNode, final String xPathString); static void writeDocumentTo(final Document dom, final OutputStream os); static DSSDocument createDssDocumentFromDomDocument(Document document, String name); static String xmlToString(final Node node); static Map<String, String> getCurrentNamespaces(); static String getXPathByIdAttribute(String uri); static String getId(String uri); static boolean isElementReference(String uri); static boolean isXPointerQuery(String uriValue); static Element createElementNS(Document documentDom, DSSNamespace namespace, DSSElement element); static void addNamespaceAttribute(Element element, DSSNamespace namespace); static final int TRANSFORMER_INDENT_NUMBER; }
@Test public void getDate() { assertNull(DomUtils.getDate("2020-02-16:T18:32:24Z")); assertNotNull(DomUtils.getDate("2020-02-16T18:32:24Z")); }