i want to write a code using Runnable method using lambda operators but i got an error of Error:(40, 33) error: lambda expressions are not supported in -source 1.7 (use -source 8 or higher to enable lambda expressions) Here is my code:`
public void countDownStart(){
handler= new Handler();
runnable= (Runnable) () -> {
handler.postDelayed((Runnable) this, 1000);
try{
SimpleDateFormat dateFormat= new SimpleDateFormat("YYYY-MM-DD");
Date futureDate= dateFormat.parse("2017-03-31");
Date currentDate= new Date();
if (!currentDate.after(futureDate)){
long diff = futureDate.getTime()- currentDate.getTime();
long days = diff / (24 * 60 * 60 * 1000);
diff -= days * (24 * 60 * 60 * 1000);
long hours = diff / (60 * 60 * 1000);
diff -= hours * (60 * 60 * 1000);
long minutes = diff / (60 * 1000);
diff -= minutes * (60* 1000);
long seconds = diff / 1000;
txtTimerDay.setText("" + String.format("%02d", days));
txtTimerHour.setText("" + String.format("%02d", hours));
txtTimerMinute.setText("" + String.format("%02d", minutes));
txtTimerSecond.setText("" + String.format("%02d", seconds));
}else{
tvEvent.setVisibility(View.VISIBLE);
tvEvent.setText("The Event Started");
textViewGone();
}
} catch (Exception e){
e.printStackTrace();
}
};
handler.postDelayed(runnable, 1 * 1000);
}