Midnight date with time zone sent to the system with an undefined time

Brief brief information about my problem first, and then details below.

I have a calendar date from 00:00:00 as the time when it is not important for business. This value is sent to the web service that generates XML, in which the value ends in the following format: 2014-09-12T07:55:07.000Z . I noticed that this is the original value converted to time zone +0 (UTC) (ours is CET, +1, but currently CEST, +2 due to DST).

Currently, I have no idea whether the system reading the XML takes into account time zones or retrieves 2014-09-12 and accepts it in time zone +2.

I noticed that sending " 2014-09-12 00:00:00 " local time (tz +2) ends up as 2014-09-11T22:00:00.000Z in XML. No big surprise, he did not convert it ... but if it is interpreted as another system, he will think that the date is a day earlier than it should be.

What can be done to make sure that this is interpreted as a destination?

I was thinking of using midday instead of midnight to make sure that changes in the time zone did not affect the interpretation, but it looked like a dirty trick. Or maybe I should fool and set the time zone on the +0 calendar so that it does not move in time when pasted into XML?


Q & A

Why are you “posting a calendar to a web service”?

The application is located in Coldfusion 7. To communicate with SOAP web services, the server generates a set of Java classes that match the definition of the argument expected by the web service. The argument appears to be one large object with many attributes and sub-attributes. Thus, it is one instance of the main Java class and uses setters and further instantiations of other classes to "populate" all attributes.

Do you need to use Calendar?

Yes, the definition of a Java object cannot be changed. He expects a calendar for all dates.

What is this format 2014-09-11T22: 00: 00.000Z?

I have no idea. This seems to be what the final date system expects.

You have to use joda

If the JODA classes do not extend the calendar and are not compatible with Java 1.3 (the current version of Java on the Coldfusion server is yes, it is old), I doubt it will work.

How much can you do on another system?

The other system is the responsibility of the other team and is apparently very difficult to change. I expect a solution to be found on the side of our application.

+6
source share
1 answer

Although the time value in your calendar object is not important for your company, it is important to use a web service that you use and do not control. The calendar object indicates a point in time, so you need to make sure that the moment on that day is important to you. I recommend you use noon, as you said. I also recommend creating a Calendar object in the UTC time zone:

 Calendar myCalendar=Calendar.getInstance(TimeZone.getTimeZone("UTC")); 
+4
source

Source: https://habr.com/ru/post/975182/


All Articles