Example usage for javax.xml.datatype XMLGregorianCalendar getMonth

List of usage examples for javax.xml.datatype XMLGregorianCalendar getMonth

Introduction

In this page you can find the example usage for javax.xml.datatype XMLGregorianCalendar getMonth.

Prototype

public abstract int getMonth();

Source Link

Document

Returns the month of this calendar or DatatypeConstants#FIELD_UNDEFINED .

Usage

From source file:se.skl.skltpservices.npoadapter.mapper.util.EHRUtil.java

/**
 * Returns a {@link Date} date and time representation.
 *
 * @param cal/* ww  w .  ja  va2s  .  com*/
 *            the actual date and time.
 * @return the {@link Date} representation.
 */
public static Date toDate(XMLGregorianCalendar cal) {
    if (cal != null) {
        final Calendar c = Calendar.getInstance();

        c.set(Calendar.DATE, cal.getDay());
        c.set(Calendar.MONTH, cal.getMonth() - 1);
        c.set(Calendar.YEAR, cal.getYear());
        c.set(Calendar.DAY_OF_MONTH, cal.getDay());
        c.set(Calendar.HOUR_OF_DAY, cal.getHour());
        c.set(Calendar.MINUTE, cal.getMinute());
        c.set(Calendar.SECOND, cal.getSecond());
        c.set(Calendar.MILLISECOND, cal.getMillisecond());

        return c.getTime();
    }
    return null;
}