diff options
author | PJ Fanning <fanningpj@apache.org> | 2023-07-24 19:59:45 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2023-07-24 19:59:45 +0000 |
commit | c6aa3a1318271b25fe90a34fca3d6f1de0a813fc (patch) | |
tree | b0f55b64eaf0dee32d8ddd038d0a2abdf797a013 /poi/src | |
parent | 1f446e0aefd61898e741f7ed999fcaf6f0488951 (diff) | |
download | poi-c6aa3a1318271b25fe90a34fca3d6f1de0a813fc.tar.gz poi-c6aa3a1318271b25fe90a34fca3d6f1de0a813fc.zip |
[github-488] Round up seconds in CellElapsedFormatter. Thanks to Anthony Schott. This closes #488
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1911254 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi/src')
-rw-r--r-- | poi/src/main/java/org/apache/poi/ss/format/CellElapsedFormatter.java | 2 | ||||
-rw-r--r-- | poi/src/test/java/org/apache/poi/ss/format/TestCellFormat.java | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/poi/src/main/java/org/apache/poi/ss/format/CellElapsedFormatter.java b/poi/src/main/java/org/apache/poi/ss/format/CellElapsedFormatter.java index 43069d2eab..93fc537d12 100644 --- a/poi/src/main/java/org/apache/poi/ss/format/CellElapsedFormatter.java +++ b/poi/src/main/java/org/apache/poi/ss/format/CellElapsedFormatter.java @@ -59,7 +59,7 @@ public class CellElapsedFormatter extends CellFormatter { val = elapsed / factor; else val = elapsed / factor % modBy; - if (type == '0') + if (type == '0' || type == 's') return Math.round(val); else return (long) val; diff --git a/poi/src/test/java/org/apache/poi/ss/format/TestCellFormat.java b/poi/src/test/java/org/apache/poi/ss/format/TestCellFormat.java index 89badeded2..d9572117f4 100644 --- a/poi/src/test/java/org/apache/poi/ss/format/TestCellFormat.java +++ b/poi/src/test/java/org/apache/poi/ss/format/TestCellFormat.java @@ -1046,4 +1046,11 @@ class TestCellFormat { .map(CellFormatPart.NAMED_COLORS::get) .forEach(Assertions::assertNotNull); } + + @Test + void testElapsedSecondsRound() { + CellFormatPart part = new CellFormatPart("[h]\\h m\\m s\\s"); + assertNotNull(part); + assertEquals("0h 0m 9s", part.apply(0.0001).text); + } } |