Hibernate 时间查询错误

xiaoxiao2021-02-28  149

1、错误Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff] 在hibernate连接数据查询的时候,Date类型的数据在查询的时候需要转为Timestamp类型。

2、错误’0000-00-00 00:00:00’ can not be represented as java.sql.Timestamp 出现这种错误是因为数据库中对应的字段值为空

3、String 类型转为Date类型 Date beginDate = sdf.parse(“2017-08-01 00:30:00”);

SimpleDateFormat format = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”); /将Date格式化/ String sdate = format.format(beginDate); /将String 转为转为Timestamp 类型/ Timestamp sTimestamp = Timestamp.valueOf(sdate);

转载请注明原文地址: https://www.6miu.com/read-20946.html

最新回复(0)