You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Benedikt Ritter (JIRA)" <ji...@apache.org> on 2014/03/03 09:02:22 UTC

[jira] [Updated] (LANG-982) DurationFormatUtils.formatDuration(61999, "s.SSSS") - ms field size should be 4 digits

     [ https://issues.apache.org/jira/browse/LANG-982?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benedikt Ritter updated LANG-982:
---------------------------------

    Component/s: lang.time.*

> DurationFormatUtils.formatDuration(61999, "s.SSSS") - ms field size should be 4 digits
> --------------------------------------------------------------------------------------
>
>                 Key: LANG-982
>                 URL: https://issues.apache.org/jira/browse/LANG-982
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.time.*
>            Reporter: Sebb
>             Fix For: Patch Needed
>
>
> 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.



--
This message was sent by Atlassian JIRA
(v6.2#6252)