1

Here I present you my JAVA code in Eclipse for some appointments' dates. I am trying to create some appointments with JAVA servlets and mySQL:

        Date today = new Date();
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
        Date myDate = null;
        try {
            myDate = sdf1.parse("2017-06-22");
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        System.out.println("My Date is"+myDate);    
        System.out.println("Today Date is"+today);
        if (today.compareTo(myDate)<0)
            System.out.println("Today Date is Lesser than my Date");
        else if (today.compareTo(myDate)>0)
            System.out.println("Today Date is Greater than my date"); 
        else
            System.out.println("Both Dates are equal"); 
 }

I am trying to create a delete form in Java of some appointments for some patients. I would like some help on how to compare the "today" date (present date) with another date. And how to check if the appointment that the patient is trying to delete is not in less than 3 days. Any ideas?

Thanks in advance.

Ole V.V.
  • 81,772
  • 15
  • 137
  • 161
  • 1
    Always search Stack Overflow thoroughly before posting. You'll find all the basic date-time questions have been asked and answered already. – Basil Bourque Jul 02 '17 at 02:28
  • And always use the modern Java date and time API when you can. Which is practically always. It’s so much better than the long outdated `Date` and `SimpleDateFormat`. Some of the answers to the linked question show you how. – Ole V.V. Jul 02 '17 at 07:44

0 Answers0