Java XML Date Create getXMLGregorianCalendar(TimeZone timeZone, Locale locale)

Here you can find the source of getXMLGregorianCalendar(TimeZone timeZone, Locale locale)

Description

get XML Gregorian Calendar

License

MIT License

Declaration

public static XMLGregorianCalendar getXMLGregorianCalendar(TimeZone timeZone, Locale locale)
            throws DatatypeConfigurationException 

Method Source Code

//package com.java2s;
/*!/*from  w w  w.j  av  a 2 s. c  o  m*/
 * mifmi-commons4j
 * https://github.com/mifmi/mifmi-commons4j
 *
 * Copyright (c) 2015 mifmi.org and other contributors
 * Released under the MIT license
 * https://opensource.org/licenses/MIT
 */

import java.util.GregorianCalendar;

import java.util.Locale;

import java.util.TimeZone;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

public class Main {
    public static XMLGregorianCalendar getXMLGregorianCalendar(TimeZone timeZone, Locale locale)
            throws DatatypeConfigurationException {
        return DatatypeFactory.newInstance().newXMLGregorianCalendar(getGregorianCalendar(timeZone, locale));
    }

    public static GregorianCalendar getGregorianCalendar(TimeZone timeZone, Locale locale) {
        GregorianCalendar gcal;
        if (timeZone == null) {
            if (locale == null) {
                gcal = new GregorianCalendar();
            } else {
                gcal = new GregorianCalendar(locale);
            }
        } else {
            if (locale == null) {
                gcal = new GregorianCalendar(timeZone);
            } else {
                gcal = new GregorianCalendar(timeZone, locale);
            }
        }
        return gcal;
    }
}

Related

  1. getXmlGregCal(Date dt)
  2. getXMLGregorianCalendar()
  3. getXMLGregorianCalendar(Date date)
  4. getXMLGregorianCalendar(Date date)
  5. getXmlGregorianCalendar(String unixTime)
  6. getXMLGregorianCalendarFromDate(Date date)
  7. getXMLGregorianCalendarFromDate(Date date)
  8. getXMLGregorianCalendarValue( Date date)
  9. getXMLGregorianCalenderDate()