According to http://apiux.com/2013/03/20/5-laws-api-dates-and-times/ we should use ISO 8601 to format date. The output on my system is:
$ date --iso-8601=ns
2020-10-29T10:38:59,112768965+01:00
Which java formatter parse this string correctly? I've tried DateTimeFormatter.ISO_OFFSET_DATE_TIME and a few others, and they don't like this format. I expect that such a format should be supported out-of-the-box, as Oracle claims on its page https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html but it isn't.
Another thing is that Spring announced wide support for date format: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes#date-time-conversion-in-web-applications. I can then set all properties to "iso". But which exactly format is it, and where is it in use?
I see two problems here.
- one is https://github.com/FasterXML/jackson-databind/issues/2643 (offset with or without semicolon)
- the second one is existence of nano/milliseconds (I want to use them)
I would like to have consistent approach to date format across whole application, and I would like to use standard to easily integrate with the rest of the world. What should I use?
Edit: In the end it happened that there are a few things to consider:
- Example from Linux console was artificial, as I didn't notice this format with "," in real world. It turned out, that it's slightly inconsistently supported in Java world
- ObjectMapper, ModelMapper and OffsetDateTime makes Date object conversion different, especially conversion to ISO format ('Z' or '00:00')
- Offset definition in form of "0000" also existed in Java, and I had to fix my conversion