i have a class which is an ID Card System, on the cards i have a variable which accepts a date as a string in the format "dd/mm/yyyy", This works fine and gets passed through as a string.
On the ID now these are only active for some days so i have a method called isTimeValid, which will extract this date and check to see if the date on the card is valid with real time data like the time now.
Heres My Code:
public void isTimeValid()
{
Calendar dateTime = Calendar.getInstance();
String dateStr = this.dateValid;
DateFormat formatter;
Date date;
formatter = new SimpleDateFormat("dd-MM-yy");
date = (Date) formatter.parse(dateStr);
if (date.equals(dateTime))
{
System.out.println("Card Is Valid");
} else
{
System.out.println("Card Not Valid");
}
}
This doesn't work, for me what am i doing incorrect?
Thanks

New Topic/Question
Reply



MultiQuote





|