aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--poi/src/main/java/org/apache/poi/ss/format/CellElapsedFormatter.java2
-rw-r--r--poi/src/test/java/org/apache/poi/ss/format/TestCellFormat.java7
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);
+ }
}