Gets the time in millis from XMLGregorianCalendar - Java XML

Java examples for XML:XML Calendar

Description

Gets the time in millis from XMLGregorianCalendar

Demo Code


//package com.java2s;

import javax.xml.datatype.XMLGregorianCalendar;

public class Main {
    /**// ww  w  .ja  va  2  s  .c o  m
     * Gets the time in millis.
     *
     * @param xmlCalendar
     *            the xml calendar
     * @return the current time as UTC milliseconds from the epoch.
     */
    public static long getTimeInMillis(XMLGregorianCalendar xmlCalendar) {
        if (xmlCalendar == null) {
            throw new IllegalArgumentException(
                    "Parameter 'XMLGregorianCalendar xmlCalendar' is null!");
        }

        return xmlCalendar.toGregorianCalendar().getTimeInMillis();
    }
}

Related Tutorials