[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 9378
  • Last Modified:

How do I get the XMLGregorianCalendar current time GMT?

Hello,

How do I get the current datetime using XMLGregorianCalendar in GMT format?  I've tried the below method but that returns it based on my computers time I believe.  

 private XMLGregorianCalendar getCurrentDateTime(){
        GregorianCalendar gc = new GregorianCalendar();
        DatatypeFactory dtf=null;
        try {
            dtf = DatatypeFactory.newInstance();
        } catch (DatatypeConfigurationException ex) {
            Logger.getLogger(SyncServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return dtf.newXMLGregorianCalendar(gc);
    }

Thanks!
0
cgray1223
Asked:
cgray1223
1 Solution
 
objectsCommented:
gc.setTimeZone(TimeZone.getTimeZone("GMT"));
0
 
TripplebeamCommented:
try this page for info:
http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/datatype/XMLGregorianCalendar.html
<a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/datatype/XMLGregorianCalendar.html>TRY THIS</a>

Open in new window

0
 
cgray1223Author Commented:
Thanks for the help, why do I get a Z at the end?

2010-04-07T16:44:51.000Z
1

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now