Ive made an IDCard class with a subclass called VisitorID.
The visitor ID is only valid for a certain date so ive created a method to check this. It was working for me but now it isnt and i cant see what ive done wrong.
Below is the method, when i call this method from my test class it returns ID card is not valid regardless of if its a correct or incorrect date. "dateValid" is the date string input when creating the Visitor ID card and is in the format dd/mm/yyyy.
Code :public void isValid() { Calendar cal = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); if(sdf.format(cal.getTime()).equals(dateValid)) { System.out.println("Visitor ID Card is Valid"); } else System.out.println("Visitor ID Card is not valid"); }
Any help appreciated
