Java XML Date Create xmlDateToLong(String s)

Here you can find the source of xmlDateToLong(String s)

Description

xml Date To Long

License

Open Source License

Declaration

public static long xmlDateToLong(String s) 

Method Source Code


//package com.java2s;
/*//from w w  w  . ja  va2 s . com
 * Copyright (c) 2004-2012 The YAWL Foundation. All rights reserved.
 * The YAWL Foundation is a collaboration of individuals and
 * organisations who are committed to improving workflow technology.
 *
 * This file is part of YAWL. YAWL is free software: you can
 * redistribute it and/or modify it under the terms of the GNU Lesser
 * General Public License as published by the Free Software Foundation.
 *
 * YAWL is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
 * Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with YAWL. If not, see <http://www.gnu.org/licenses/>.
 */

import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;

import javax.xml.datatype.XMLGregorianCalendar;

public class Main {
    public static long xmlDateToLong(String s) {
        if (s == null)
            return -1;
        try {
            XMLGregorianCalendar cal = DatatypeFactory.newInstance().newXMLGregorianCalendar(s);
            return cal.toGregorianCalendar().getTimeInMillis();
        } catch (DatatypeConfigurationException dce) {
            return -1;
        }
    }
}

Related

  1. toXMLGregorianCalendar(String stringTypeDate)
  2. toXMLGregorianCalendar(Timestamp timestamp)
  3. xmlCalendarToCalendar(XMLGregorianCalendar cal)
  4. xmlCalendarToCalendar(XMLGregorianCalendar xmlCalendar)
  5. xmlDateToDate(XMLGregorianCalendar xmlCalendar)
  6. xmlGCtoMillis(XMLGregorianCalendar gc)
  7. xmlGregorian2Gregorian(XMLGregorianCalendar xmlGC)
  8. xmlGregorianCalendar()
  9. xmlGregorianCalendarToDate(XMLGregorianCalendar cal)