[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
This commit is contained in:
PJ Fanning 2023-07-24 19:59:45 +00:00
parent 1f446e0aef
commit c6aa3a1318
2 changed files with 8 additions and 1 deletions

View File

@ -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;

View File

@ -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);
}
}