Java 休眠当前日期条件
在我的数据库中,Java 休眠当前日期条件,java,sql,hibernate,criteria,Java,Sql,Hibernate,Criteria,在我的数据库中,date以“yyyy-mm-dd hh:mm:ss”格式存储。我需要当前日期的详细信息。我使用的是hibernate标准 我已尝试使用此代码 DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(); try { criteria.add(Restrictions.eq("createdDate", dateFormat.parse(dateFormat.form
date
以“yyyy-mm-dd hh:mm:ss”格式存储。我需要当前日期的详细信息。我使用的是hibernate标准
我已尝试使用此代码
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
try {
criteria.add(Restrictions.eq("createdDate", dateFormat.parse(dateFormat.format(date))));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
但它不起作用。请建议一些解决方案请显示您收到的错误。“在我的数据库中,日期是“yyy-mm-dd hh:mm:ss”格式的?”?可能不是,您确定列的类型是字符串吗。没有错误。它没有获取正确的列。找不到行..不..它是日期格式的您能显示表定义吗?