Is the format -MM-DD for the monthly part of ISO 8601?

The Java 8 date / time API, java.time , has a MonthDay class to represent the month and day together. Thus, the Joda-Time library offers a MonthDay class.

In java.time, a method is MonthDay.toString()declared as:

Displays this month as a string, for example, -12-03.

In most classes in java.time, their method toString()outputs a standard representation of the ISO 8601 concept that they represent ( YYYY-MM-DDfor LocalDateexample), so I would expect this format to --MM-DDalso be standard.

But I could not find it in the ISO 8601 standard.

Is the month-to-day concept defined by ISO 8601, and if so, the --MM-DDstandard format?

Reference Information. I am developing a date / time API in another language.

+4
source share
1 answer

Yes, in clause 4.4, ISO 8601: 1988 says:

Note. A hyphen is also used to indicate missing components.

Thus, the format --MM-DDcorresponds to ISO 8601, where the year is omitted / missing, and paragraph 5.2.1.3d also contains an example of this format itself.

This format has disappeared in later versions of the ISO 8601 standard. However, the java.time classes continue to support the format along with the class MonthDay.

+5
source

All Articles