Search before asking
Fesod version
main
JDK version
any
Operating system
Linux
Steps To Reproduce
File file = new File("ampm.xlsx");
DataFormatData dataFormat = new DataFormatData();
dataFormat.setFormat("hh:mm:ss.000 AM/PM");
WriteCellData<BigDecimal> cell = new WriteCellData<>(new BigDecimal("42000.75"));
cell.getOrCreateStyle().setDataFormatData(dataFormat);
FesodSheet.write(file)
.head(Collections.singletonList(Collections.singletonList("time")))
.sheet()
.doWrite(Collections.singletonList(Collections.singletonList(cell)));
System.out.println(FesodSheet.read(file).sheet().doReadSync());
Current Behavior
[{0=hh:mm:ss42000.750 AM/PM}]
A format containing both fractional seconds and an AM/PM marker is not recognised as a date, so DataFormatter.format takes the number branch: numPattern matches the 000, and createNumberFormat builds a DecimalFormat("hh:mm:ss.000 AM/PM"), which leaves the pattern letters as literal text around the raw serial.
Affected formats include hh:mm:ss.000 AM/PM, h:mm:ss.0 AM/PM, mm:ss.0 AM/PM and m/d/yy h:mm:ss.000 AM/PM. Without the AM/PM part (hh:mm:ss.000) or without the fractional seconds (hh:mm:ss AM/PM) detection works, so only the combination is affected.
Expected Behavior
Anything else?
Found while writing the tests in #1110.
fesod: "^[\\[\\]yYmMdDhHsS\\-T/\u5e74\u6708\u65e5,. :\"\\\\]+0*[ampAMP/]*$"
POI: "^[\\[\\]yYmMdDhHsS\\-T/\u5e74\u6708\u65e5,. :\"\\\\]+0* ?[ampAMP/]*$"
Are you willing to submit a PR?
Search before asking
Fesod version
main
JDK version
any
Operating system
Linux
Steps To Reproduce
Current Behavior
A format containing both fractional seconds and an AM/PM marker is not recognised as a date, so
DataFormatter.formattakes the number branch:numPatternmatches the000, andcreateNumberFormatbuilds aDecimalFormat("hh:mm:ss.000 AM/PM"), which leaves the pattern letters as literal text around the raw serial.Affected formats include
hh:mm:ss.000 AM/PM,h:mm:ss.0 AM/PM,mm:ss.0 AM/PMandm/d/yy h:mm:ss.000 AM/PM. Without the AM/PM part (hh:mm:ss.000) or without the fractional seconds (hh:mm:ss AM/PM) detection works, so only the combination is affected.Expected Behavior
Anything else?
Found while writing the tests in #1110.
Are you willing to submit a PR?