4
EasyExcel 读取excel, 日期格式的列,
java里面定义的 实体类, 对应的格式是 LocalDateTime
User { LocalDataTime ctime }
触发Bug的代码
String path = "/Users/daniellu/Desktop/eladmin_user.xlsx";
final List<User> userList = EasyExcel.read(path).sheet(0).head(User.class).doReadSync();
System.out.println(userList);
@Data
public class User {
/** ID */
@ExcelProperty(index = 0)
private Integer id;
/** 姓名 */
@ExcelProperty(index = 1)
private String name;
/** 性别 */
@ExcelProperty(index = 2)
private String sex;
// @ExcelProperty(index = 3)
// private LocalDate birth;
@ExcelProperty(index = 4)
private String nation;
/** 身份证号 */
@ExcelProperty(index = 5)
private String idNumber;
/** 密码 */
@ExcelProperty(index = 6)
private String password;
/** 最近登陆时间 */
@ExcelProperty(index = 7)
private Integer lastLoginTime;
@ExcelProperty(index = 9)
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
private LocalDateTime ctime;
/** 报名step */
@ExcelProperty(index = 10)
private Integer enrollStep;
@ExcelProperty(index = 11)
private Integer studentInfoId;
}
提示的异常或者没有达到的效果 Caused by: com.alibaba.excel.exception.ExcelDataConvertException: Converter not found, convert STRING to java.time.LocalDateTime at com.alibaba.excel.util.ConverterUtils.doConvertToJavaObject(ConverterUtils.java:130)