ISODateTimeFormat: make millis optional in dateTime format by default
See original GitHub issueWhen using joda-time to parse xsd:dateTime values, the developer is forced to choose statically whether their date is a dateTime or as dateTimeNoMillis.
However, it is not uncommon for XML parsers, transformers and XPath engines to optimise xsd:dateTime values with a ,000 fractional part, and completely strip away the milliseconds section.
Try this in Saxon 9.x (XPath 2.0) – probably the most popular XSLT 2.0 parser out there:
'2006-12-28T15:42:04.000+01:00' cast as xs:dateTime
returns
2006-12-28T15:42:04+01:00
Obviously one can create a custom parser with an optional millis part, but this is not intuitive, and certainly not a nice OOTB experience with Joda.
Therefore I propose to modify the dateTime() method to return a formatter that considers the millisecond part as optional OOTB. It doesn’t harm anybody and contributes positively to the usability of Joda.
Issue Analytics
- State:
- Created 10 years ago
- Comments:6 (3 by maintainers)
Changing the meaning of these formats at this point in Joda-Time’s life would essentially be backwards incompatible. The parser is intended for handling variable length input, whereas the
dateTime()
anddateTimeNoMillis()
handle output and parsing of fixed length formats.The returned formatter prints and parse
should beThe returned formatter prints and parses
.See {@link #dateTimeParser()} for a more flexible parse
should beSee {@link #dateTimeParser()} for a more flexible parser
. This same text occurs 26 and 13 times, respectively.