简体   繁体   中英

Comparing dates java.util.date with Date datatype in db

I have java.util.date and there is a column date in Oracle db table of DATE datatype and value is stored in format 31-JAN-36. I want to compare java.util.date with the date column in db and return if both matches. I tried no of ways using to_char, to_date functions but it's not working, can any help please help me on this.

Thanks.

Use the SimpleDateFormat:

Date date = ..your date..
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-YY");
String where = "p.starts_on = '" + sdf.format(date) + "'";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM