Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Duplicate
-
2.1
-
None
-
None
-
None
-
Operating System: Linux
Platform: Other
-
36522
Description
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")