commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 36522] New: - DurationFormatUtils.formatDurationWords() incorrectly formats values ending in 1 but greater than 1
Date Tue, 06 Sep 2005 15:45:18 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=36522>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=36522

           Summary: DurationFormatUtils.formatDurationWords() incorrectly
                    formats values ending in 1 but greater than 1
           Product: Commons
           Version: 2.1 Final
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Lang
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: asf.robmoore@xoxy.net


Currently, values ending in 1 but greater than 1 (41, for example) return a
non-plural response (second, hour, day, etc). The culprit code appears to be at
the end of the method:

// handle plurals
duration = StringUtils.replaceOnce(duration, "1 seconds", "1 second");
duration = StringUtils.replaceOnce(duration, "1 minutes", "1 minute");
duration = StringUtils.replaceOnce(duration, "1 hours", "1 hour");
duration = StringUtils.replaceOnce(duration, "1 days", "1 day");

One approach to fix this might be to use a regular expression to replace only if
 1 appears as a single digit rather than with another digit. 

I'm thinking of something like: (duration.replaceFirst("([^\\d])(\\d) seconds",
"$1$2 second")

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message