I want to check two dates here if both dates are equal then the timer should run else not.So, to check that i have taken two string here one is the given date that i have provided and other date i have used date class that will fetch current date.I have tried to compare both dates:
Date date1 = new Date();//Fetch currentdate
String dtStart = "2019-02-20";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
Date date = format.parse(dtStart);
} catch (ParseException e) {
e.printStackTrace();
}
I am comparing here two dates if both dates are equal then the timer should run else not.But while comparing i am getting null object reference exception here:
if(date.compareTo(date1)== 0) {
timer(diff);
Intent intent = getIntent();
String imageURL = intent.getStringExtra("urlKey");
initViews();
displayImage(imageURL);
setListeners();
}
else
{
Toast.makeText(getApplicationContext(), "Time Expired", Toast.LENGTH_SHORT).show();
}