Browse Source

修改日期格式化案例

developing
Jiaju Zhuang 5 months ago
parent
commit
c52385f05b
  1. 8
      easyexcel-test/src/test/java/com/alibaba/easyexcel/test/core/dataformat/DateFormatTest.java
  2. BIN
      easyexcel-test/src/test/resources/dataformat/dataformat.xls
  3. BIN
      easyexcel-test/src/test/resources/dataformat/dataformat.xlsx

8
easyexcel-test/src/test/java/com/alibaba/easyexcel/test/core/dataformat/DateFormatTest.java

@ -47,15 +47,17 @@ public class DateFormatTest {
List<DateFormatData> list =
EasyExcel.read(file, DateFormatData.class, null).locale(Locale.CHINA).sheet().doReadSync();
for (DateFormatData data : list) {
if (data.getDateStringCn() != null && !data.getDateStringCn().equals(data.getDate())) {
log.info("date:cn:{},{}", data.getDateStringCn(), data.getDate());
if (!Objects.equals(data.getDateStringCn(), data.getDate()) && !Objects.equals(data.getDateStringCn2(),
data.getDate())) {
log.info("date:cn:{},{},{}", data.getDateStringCn(), data.getDateStringCn2(), data.getDate());
}
if (data.getNumberStringCn() != null && !data.getNumberStringCn().equals(data.getNumber())) {
log.info("number:cn{},{}", data.getNumberStringCn(), data.getNumber());
}
}
for (DateFormatData data : list) {
// The way dates are read in Chinese is different on Linux and Mac, so it is acceptable if it matches either one.
// The way dates are read in Chinese is different on Linux and Mac, so it is acceptable if it matches
// either one.
// For example, on Linux: 1-Jan -> 1-1月
// On Mac: 1-Jan -> 1-一月
Assertions.assertTrue(

BIN
easyexcel-test/src/test/resources/dataformat/dataformat.xls

Binary file not shown.

BIN
easyexcel-test/src/test/resources/dataformat/dataformat.xlsx

Binary file not shown.
Loading…
Cancel
Save