-1

I’m using XMLGregorianCalendar in my spring boot app to define a date range and using the same in the input while calling an REST service. However, when I’m calling the service from my local, I see the date is being set as “2019-06-17-04:00” in the REST input XML. If I run the same app in Openshift container, the date is being set as “2019-06-17Z” in the request XML. Can you please let me know the reason for this? And what is the difference between these two date formats?

XMLGregorianCalendar toDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar());
XMLGregorianCalendar fromDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(<some date>);
Mike Lowery
  • 2,630
  • 4
  • 34
  • 44
pai
  • 33
  • 1
  • 5
  • One is a timestamp with date + time, the other is just a date. Is that what you ask? – GhostCat Jun 17 '19 at 18:59
  • Is there a “T” in the -04:00 one? At, say, 22:00 (10:00 PM) US/Eastern time, it could be 2019-06-17T-04:00, but at the same instant it would be 2019-06-18Z in UTC. – David Maze Jun 17 '19 at 20:15
  • No. there is no "T" in the time. exactly what time does “2019-06-17Z” point to? – pai Jun 17 '19 at 21:24
  • 1
    “2019-06-17Z” is presumably intended to mean “2019-06-17T00:00:00Z”, i.e., the very first instant of June 17th 2019, as measured in UTC. Whether it's standard-conformant I'm not so sure. –  Jun 17 '19 at 22:46

1 Answers1

0

The suffix on both inputs refer to offset-from-UTC, presumably.

  • The -04:00 on 2019-06-17-04:00 means four hours behind UTC.
  • the Z on 2019-06-17Z means zero hours-minutes-seconds from UTC, that is, UTC itself. The Z is pronounced “Zulu” and is short for +00:00:00.

However, both of your inputs are meaningless. Assigning an offset to a date without a time-of-day makes no sense. Indeed, on some days such as a Daylight Saving Time (DST) cutover, a date might involve two offsets.

You should report these values to the publisher as erroneous. Educate them about the ISO 8691 standard for reporting date-time values.

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154