AbsoluteDate print method and ISO 8601

I am trying to write AbsoluteDate to file. I am using the “toString” method with various variations (defined zone, defined time scale) but cannot force it to write UTC date with “Z” at the end.

Here example:

AbsoluteDate date = new AbsoluteDate("2019-10-27T10:00:00.567Z",

Output is: 2019-10-27T10:00:00.567

It is not complying with ISO 8601 norm, as :

If no UTC relation information is given with a time representation, the time is assumed to be in local time.

Is there a possibility to write the date correctly without converting to Java time?

Best regards,

There is no default way to do that.
Could you file a bug report on the forge?

In the meantime, you’ll have to use a custom print method instead of the standard toString(). One way is to directly append the ‘Z’ character at the end, another way is to retrieve the components using getComponents and to format the string by yourself. The second method would also allow you to have better than millisecond precision, as the standard toString() rounds to the nearest millisecond. Beware if you go to the getComponents route that rounding is tricky with dates: if you have a date of the form 23:59:59.99999999 in a regular day or 23:59:60.99999999 on a leap seconds day, you’ll have to round to 00:00:00 next day. you can see how this is handled in DateTimeComponents.toString(final int minuteDuration).

Thanks for hints.
Probably I will try with .toDate() and then write it as ZonedDateTime.