Java XML Date to getDurationFromCalendar( final XMLGregorianCalendar cal)

Here you can find the source of getDurationFromCalendar( final XMLGregorianCalendar cal)

Description

getDurationFromCalendar.

License

Open Source License

Parameter

Parameter Description
cal a javax.xml.datatype.XMLGregorianCalendar object.

Return

a object.

Declaration

public static Duration getDurationFromCalendar(
        final XMLGregorianCalendar cal) 

Method Source Code

//package com.java2s;

import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.Duration;
import javax.xml.datatype.XMLGregorianCalendar;

public class Main {
    /**/*  w ww  .  ja  v  a2  s . co m*/
     * <p>getDurationFromCalendar.</p>
     *
     * @param cal a {@link javax.xml.datatype.XMLGregorianCalendar} object.
     * @return a {@link javax.xml.datatype.Duration} object.
     */
    public static Duration getDurationFromCalendar(
            final XMLGregorianCalendar cal) {
        Duration dur;
        try {
            dur = DatatypeFactory.newInstance().newDurationDayTime(
                    cal.getTimezone() * 60000);
        } catch (final DatatypeConfigurationException e) {
            return null;
        }
        return dur;
    }
}

Related

  1. getDate(XMLGregorianCalendar calendar)
  2. GetDateDiffInDays(XMLGregorianCalendar Calendar)
  3. getDateFromXmlGregorianCalendar(XMLGregorianCalendar da)
  4. getDateFromXMLGregorianCalendar(XMLGregorianCalendar xmlCalendar)
  5. getDateFromXMLGregorianCalendar(XMLGregorianCalendar xmlGregorianCalendar)
  6. getGmtTimeFromXMLGregorianCalendar( XMLGregorianCalendar xgcal)
  7. getLocalTimeFromXMLGregorianCalendar( XMLGregorianCalendar xgcal)
  8. getMilliseconds(XMLGregorianCalendar xmlCalendar)
  9. getNextMonthDate(GregorianCalendar calendar)