Author: fanningpj
Date: Mon Jul 24 19:59:45 2023
New Revision: 1911254

URL: http://svn.apache.org/viewvc?rev=1911254&view=rev
Log:
[github-488] Round up seconds in CellElapsedFormatter. Thanks to Anthony 
Schott. This closes #488

Modified:
    
poi/trunk/poi/src/main/java/org/apache/poi/ss/format/CellElapsedFormatter.java
    poi/trunk/poi/src/test/java/org/apache/poi/ss/format/TestCellFormat.java

Modified: 
poi/trunk/poi/src/main/java/org/apache/poi/ss/format/CellElapsedFormatter.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/format/CellElapsedFormatter.java?rev=1911254&r1=1911253&r2=1911254&view=diff
==============================================================================
--- 
poi/trunk/poi/src/main/java/org/apache/poi/ss/format/CellElapsedFormatter.java 
(original)
+++ 
poi/trunk/poi/src/main/java/org/apache/poi/ss/format/CellElapsedFormatter.java 
Mon Jul 24 19:59:45 2023
@@ -59,7 +59,7 @@ public class CellElapsedFormatter extend
                 val = elapsed / factor;
             else
                 val = elapsed / factor % modBy;
-            if (type == '0')
+            if (type == '0' || type == 's')
                 return Math.round(val);
             else
                 return (long) val;

Modified: 
poi/trunk/poi/src/test/java/org/apache/poi/ss/format/TestCellFormat.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/format/TestCellFormat.java?rev=1911254&r1=1911253&r2=1911254&view=diff
==============================================================================
--- poi/trunk/poi/src/test/java/org/apache/poi/ss/format/TestCellFormat.java 
(original)
+++ poi/trunk/poi/src/test/java/org/apache/poi/ss/format/TestCellFormat.java 
Mon Jul 24 19:59:45 2023
@@ -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);
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to