Dates Range By Using Simple 'if' in Java

public void Cheq() {

        try {
            Statement st7 = DBConnection.Conn_Statement3();
            Statement st8 = DBConnection.Conn_Statement2();
            if (cid.getSelectedItem() != null) {
                String id = cid.getSelectedItem().toString();
                String qry = "SELECT `fromdate` , `todate` FROM `Submit` WHERE `cid`= " + cid.getSelectedItem().toString();
                System.out.println("" + qry);
                ResultSet rs7 = st7.executeQuery(qry);
                while (rs7.next()) {

                    Date frm = rs7.getDate(1);
                    Date tod = rs7.getDate(2);

                    System.out.println("" + frm + ":        " + tod);

                    Date d1 =  fromdate.getDate();
                    Date d2 =  todate.getDate();
                   
                    if((d1.before(frm)&&d1.after(tod))  )
                    {
                    chq = false;
                      JOptionPane.showMessageDialog(this, "The Collections Data is Alreday Saved");
                    }
  
               }


            }
        } catch (Exception e) {

            e.printStackTrace();
        }


    }

Post a Comment

Thank You

Previous Post Next Post