[英]What approach is better of using date truncate?
What approach is better? 哪种方法更好?
1. 1。
String sql = "select count(*) from table where date = trunc(?, 'DD')";
getJdbcTemplate().queryForInt(sql, new java.sql.Date(date.getTime()))
2. 2。
String sql = "select count(*) from table where date = ?";
getJdbcTemplate().queryForInt(sql, new java.sql.Date(DateUtils.truncate(date, Calendar.DATE).getTime()))
I will prefer date = trunc(?, 'DD')
as it wont need extra third party DateUtils
to perform the truncate operation. 我将更喜欢
date = trunc(?, 'DD')
因为它不需要额外的第三方DateUtils
来执行截断操作。
Don't think their will be a noticable impact on performance if you use any of the 2 如果您使用以下两种方法中的任何一种,请不要认为它们会对性能产生显着影响
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.