Here you can find the source of getGmtTimeFromXMLGregorianCalendar( XMLGregorianCalendar xgcal)
Parameter | Description |
---|---|
xgcal | a parameter |
public static String getGmtTimeFromXMLGregorianCalendar( XMLGregorianCalendar xgcal)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; import java.util.GregorianCalendar; import java.util.TimeZone; import javax.xml.datatype.XMLGregorianCalendar; public class Main { /** String used for non-available data */ private static final String NOT_AVAILABLE = "NA"; /**//from www . j av a2s . co m * Returns a time string of the form yyyy-MM-dd'T'HH:mm:ss'Z' from the * specified XMLGregorianCalendar. If the input is null, then the value of * NOT_AVAILABLE is returned. * * @param xgcal * @return * @see #NOT_AVAILABLE */ public static String getGmtTimeFromXMLGregorianCalendar( XMLGregorianCalendar xgcal) { if (xgcal == null) { return NOT_AVAILABLE; } GregorianCalendar gcal = xgcal.toGregorianCalendar( TimeZone.getTimeZone("GMT"), null, null); // Get the date Date date = gcal.getTime(); SimpleDateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss'Z'"); // Make a new local GregorianCalendar with this date gcal = new GregorianCalendar(); gcal.setTime(date); formatter.setTimeZone(TimeZone.getTimeZone("GMT")); return formatter.format(date); } }