Java XML Date Create toDate(final XMLGregorianCalendar xml)

Here you can find the source of toDate(final XMLGregorianCalendar xml)

Description

Converts the given XML Gregorian calendar to a date.

License

Open Source License

Parameter

Parameter Description
xml The XML calendar to convert to a date, or null .

Return

The date, or null if xml was null.

Declaration

public static Date toDate(final XMLGregorianCalendar xml) 

Method Source Code


//package com.java2s;
/*//from   ww  w.  j  av a2s. c  o m
 *    Geotoolkit.org - An Open Source Java GIS Toolkit
 *    http://www.geotoolkit.org
 *
 *    (C) 2009-2012, Open Source Geospatial Foundation (OSGeo)
 *    (C) 2009-2012, Geomatys
 *
 *    This library 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;
 *    version 2.1 of the License.
 *
 *    This library 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.
 */

import java.util.Date;

import javax.xml.datatype.XMLGregorianCalendar;

public class Main {
    /**
     * Converts the given XML Gregorian calendar to a date.
     *
     * @param  xml The XML calendar to convert to a date, or {@code null}.
     * @return The date, or {@code null} if {@code xml} was null.
     *
     * @since 3.03
     */
    public static Date toDate(final XMLGregorianCalendar xml) {
        if (xml != null) {
            return xml.toGregorianCalendar().getTime();
        }
        return null;
    }
}

Related

  1. getXMLGregorianCalendar(TimeZone timeZone, Locale locale)
  2. getXMLGregorianCalendarFromDate(Date date)
  3. getXMLGregorianCalendarFromDate(Date date)
  4. getXMLGregorianCalendarValue( Date date)
  5. getXMLGregorianCalenderDate()
  6. toDate(long date)
  7. toDate(XMLGregorianCalendar cal)
  8. toDate(XMLGregorianCalendar cal)
  9. toDate(XMLGregorianCalendar date)