Unknown XMLGregorianCalendar output


Hello,

I'm using the below to get the current datetime using XMLGregorianCalendar in GMT format, but I get 2010-04-07T16:44:51.000Z.  I'm unsure what the "Z" is at the end.  The rest looks correct.

 private XMLGregorianCalendar getCurrentDateTime(){
        GregorianCalendar gc = new GregorianCalendar();
         gc.setTimeZone(TimeZone.getTimeZone("GMT"));
        DatatypeFactory dtf=null;
        try {
            dtf = DatatypeFactory.newInstance();
        } catch (DatatypeConfigurationException ex) {
            Logger.getLogger(SyncServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return dtf.newXMLGregorianCalendar(gc);
    }
cgray1223Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

VenabiliCommented:
This Z stays for RFC 822 style timezone (-0400 for example) when SimpleDateFormat is used so I suspect it is what it stays for here as well.

Why it does not get expanded is not something I can answer without seeing some more code...
0
VenabiliCommented:
What JDK do you use?
Because there used to be a bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5064587 so if you use an oldish one, this might be the explanation...
0
cgray1223Author Commented:
Hi Venabili,

i'm using 1.5....can you think of any way to format it to remove it?
0
VenabiliCommented:
Extending XMLGregorianCalendar  and using the new class (and taking care of it there) is the only fast way I can think of.

http://www.coderanch.com/t/224752/Web-Services/java/Jaxb-display-instead-Z-timezone shows an example for it.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.