Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
DurationFormatUtils.formatDuration(61999, "s.SSSS") generates the wrong number of places for the millisecond field. It should produce 61.0999 but it generates 61.999.
This is an unlikely format, but there is no indication that the millisecond field is a maximum of 3 digits when it happens to follow a seconds field.
This issue occurs because of the way the code attempts to ensure that 3 places are shown in a format if milliseconds follows seconds.
The code currently adds 1000 and then drops the first digit.
The simplest way to allow an arbitrary number of digits is to use at least 3 for the count field.
Alternatively, if exactly 3 digits are required it would be simpler to just use a count of 3.