Java XML Date Create toXMLGregorianCalendar(String stringTypeDate)

Here you can find the source of toXMLGregorianCalendar(String stringTypeDate)

Description

to XML Gregorian Calendar

License

Apache License

Declaration

public static XMLGregorianCalendar toXMLGregorianCalendar(String stringTypeDate)
        throws DatatypeConfigurationException 

Method Source Code


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

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

public class Main {

    public static XMLGregorianCalendar toXMLGregorianCalendar(String stringTypeDate)
            throws DatatypeConfigurationException {
        String yyyy = stringTypeDate.substring(0, 4);
        String mm = stringTypeDate.substring(5, 7);
        String dd = stringTypeDate.substring(8, 10);
        String hh = stringTypeDate.substring(11, 13);
        String mi = stringTypeDate.substring(14, 16);
        String ss = stringTypeDate.substring(17, 19);
        int iyyyy = Integer.parseInt(yyyy);
        int imm = Integer.parseInt(mm);
        int idd = Integer.parseInt(dd);
        int ihh = Integer.parseInt(hh);
        int imi = Integer.parseInt(mi);
        int iss = Integer.parseInt(ss);
        DatatypeFactory dataTypeFactory = DatatypeFactory.newInstance();
        return dataTypeFactory.newXMLGregorianCalendar(iyyyy, imm, idd, ihh, imi, iss, 0, 0);
    }/*from   w  w w . jav a 2  s .  c o  m*/
}

Related

  1. toXMLGregorianCalendar(Date date)
  2. toXMLGregorianCalendar(Date date, TimeZone timeZone, Locale locale)
  3. toXmlGregorianCalendar(GregorianCalendar calendar)
  4. toXMLGregorianCalendar(long dateInMillis)
  5. toXMLGregorianCalendar(long timestamp)
  6. toXMLGregorianCalendar(Timestamp timestamp)
  7. xmlCalendarToCalendar(XMLGregorianCalendar cal)
  8. xmlCalendarToCalendar(XMLGregorianCalendar xmlCalendar)
  9. xmlDateToDate(XMLGregorianCalendar xmlCalendar)