Java XML Date to getDateFromXmlGregorianCalendar(XMLGregorianCalendar da)

Here you can find the source of getDateFromXmlGregorianCalendar(XMLGregorianCalendar da)

Description

get Date From Xml Gregorian Calendar

License

Apache License

Declaration

public static Date getDateFromXmlGregorianCalendar(XMLGregorianCalendar da) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import javax.xml.datatype.XMLGregorianCalendar;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {
    public static Date getDateFromXmlGregorianCalendar(XMLGregorianCalendar da) {
        if (da != null) {
            int year = da.getYear();
            int month = da.getMonth();
            int day = da.getDay();
            int hour = da.getHour();
            int minute = da.getMinute();
            int second = da.getSecond();
            Calendar calendar = Calendar.getInstance();
            calendar.set(year, month - 1, day, hour, minute, second);
            Date date = calendar.getTime();
            return date;
        } else {/*from  w w  w . j  ava  2  s . co m*/
            return null;
        }

    }

    public static String getDay() {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        return sdf.format(date);
    }
}

Related

  1. convertXMLGregorianCalendarToDate(XMLGregorianCalendar xmlGregorianCalendar)
  2. ConvertXMLGregorianCalenderToString(XMLGregorianCalendar Calendar, String Format)
  3. getDate(XMLGregorianCalendar calendar)
  4. getDate(XMLGregorianCalendar calendar)
  5. GetDateDiffInDays(XMLGregorianCalendar Calendar)
  6. getDateFromXMLGregorianCalendar(XMLGregorianCalendar xmlCalendar)
  7. getDateFromXMLGregorianCalendar(XMLGregorianCalendar xmlGregorianCalendar)
  8. getDurationFromCalendar( final XMLGregorianCalendar cal)
  9. getGmtTimeFromXMLGregorianCalendar( XMLGregorianCalendar xgcal)