Here you can find the source of getXMLDate(Element e, String attrName)
public static Date getXMLDate(Element e, String attrName)
//package com.java2s; // modify it under the terms of the GNU General Public License import java.util.Date; import org.w3c.dom.Element; public class Main { public static Date getXMLDate(Element e, String attrName) { String s = e.getAttribute(attrName); if (s == null || s.length() == 0) return null; try {//from www . java2 s . c o m return parseDate(s); } catch (Exception exc) { return null; } } public static String getAttribute(Element e, String attrName, String def) { String result = e.getAttribute(attrName); if (!hasValue(result)) result = def; return result; } public static Date parseDate(String d) throws IllegalArgumentException { if (d == null || d.length() == 0) return null; if (!d.startsWith("@")) throw new IllegalArgumentException(); return new Date(Long.parseLong(d.substring(1))); } public static boolean hasValue(String val) { return (val != null && val.length() > 0); } }