Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
通过日期格式的 java 结果从 MYSQL 获取日期后,如何将其与从 java netbeans 中的 jtextbox 作为字符串获取的日期进行比较?
取决于日期格式,TextField您可以使用DateFormat如下方式获取日期:
TextField
DateFormat
DateFormat df = new SimpleDateFormat("MM/dd/yyyy");//put prefer format indide it Date d1 = format.parse(jtextfielddate.getText());
现在您可以轻松地将其与从数据库(Date d=rs.getDate("date");)中检索到的日期进行比较:
Date d=rs.getDate("date");
if(d1==d) { //do something }