Example usage for javax.xml.datatype XMLGregorianCalendar setMonth

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

Introduction

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

Prototype

public abstract void setMonth(int month);

Source Link

Document

Set month.

Usage

From source file:org.techytax.util.DateHelper.java

public static XMLGregorianCalendar getDate(String date_str) throws Exception {
    XMLGregorianCalendar calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar();
    Date date = stringToDate(date_str);
    calendar.setDay(getDay(date));//from  ww w  . j  av a2 s  . c  o m
    calendar.setMonth(getMonth(date) + 1);
    calendar.setYear(getYear(date));
    return calendar;
}

From source file:org.techytax.util.DateHelper.java

public static XMLGregorianCalendar getDateForXml(Date date) {
    XMLGregorianCalendar calendar = null;
    try {/*from   w w  w .  j  a  v a2  s . co m*/
        calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar();
    } catch (DatatypeConfigurationException e) {
        e.printStackTrace();
    }
    calendar.setDay(getDay(date));
    calendar.setMonth(getMonth(date) + 1);
    calendar.setYear(getYear(date));
    calendar.setHour(0);
    calendar.setMinute(0);
    calendar.setSecond(0);
    return calendar;
}