Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//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 {
            return parseDate(s);
        } catch (Exception exc) {
            return null;
        }
    }

    private static Date parseDate(String d) throws IllegalArgumentException {
        if (!d.startsWith("@"))
            throw new IllegalArgumentException();
        return new Date(Long.parseLong(d.substring(1)));
    }
}