Closed PeterBowman closed 5 years ago
Does inserting .truncatedTo(ChronoUnit.MILLIS)
before formatting the date fix the problem?
Does inserting
.truncatedTo(ChronoUnit.MILLIS)
before formatting the date fix the problem?
It definitely does, good catch! It works with ChronoUnit.MICROS
, too, and fails with ChronoUnit.NANOS
- according to https://www.mediawiki.org/wiki/Timestamp.
I noticed a problem when using the conflict-check signature of
edit()
:https://github.com/MER-C/wiki-java/blob/08a103769d3eb85fb0ec5b50817ce091b1a977fa/src/org/wikipedia/Wiki.java#L2075
The server returns a response that follows like so:
So, the formatted timestamp reads
2019-11-04T11:29:06.6517352Z
. However, https://www.mediawiki.org/wiki/Timestamp states:Emphasis mine. The timestamp returned by
convertToString
has an additional digit that exceeds the supported microsecond precision, which I guess is the root of the problem:https://github.com/MER-C/wiki-java/blob/08a103769d3eb85fb0ec5b50817ce091b1a977fa/src/org/wikipedia/Wiki.java#L8277-L8282
I started noticing this after the breaking change announced at https://lists.wikimedia.org/pipermail/mediawiki-api-announce/2019-June/000146.html (2019-06-21). Not sure whether other components of Wiki.java could be affected. As a temporary workaround, I use the following code in the snippet above, stripping the fractions of second altogether.
By the way, even if
yyyy-MM-dd'T'HH:mm:ss.nnnnnnZ
would seem to stick to only six decimals, Java adds additional stuff with zero-padding beyond the microsecond digit (2019-11-04T11:28:17.650649200+0000
) and MW complains again. The trailing+0000
is harmless, e.g.2019-07-29T07:58:10+0000
works fine.