标签:com art common datetime pre ons orm 日期格 string
错误写法
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
QueryWrapper query = new QueryWrapper();
query.ge("create_time", LocalDateTime.parse("2019-05-13 23:00:00", df));
//也不正确
query.ge(Entity::getDate,start);
正确写法
使用 日期格式化类DateFormatUtils【org.apache.commons.lang3.time.DateFormatUtils】
query.apply("UNIX_TIMESTAMP(create_time) >= UNIX_TIMESTAMP(‘" + "2019-05-12 03:00:00" + "‘)");
String strStart= DateFormatUtils.format(start,"yyyy-MM-dd HH:mm:ss");
//"2019-05-12 03:00:00"
query.apply("UNIX_TIMESTAMP(create_time) >= UNIX_TIMESTAMP(‘" +strStart + "‘)");
标签:com art common datetime pre ons orm 日期格 string
原文地址:https://www.cnblogs.com/z_lb/p/12813756.html