Whenever I use my SimpleDateFormat
in android it keep giving me the error call requires API level 24. Which doesn't make sense since I refer to this tutorial which was a couple of years old.
This is the code that giving out the error
SimpleDateFormat formatter = new SimpleDateFormat("EEE,dd MMM,yyyy HH:mm:ss");
I even try but it's still not working
SimpleDateFormat formatter = new SimpleDateFormat("EEE,dd MMM,yyyy HH:mm:ss",Locale.US);
Here is my method where I'm having problem with
public static long getDateInMillis(String srcDate) {
SimpleDateFormat formatter = new SimpleDateFormat("EEE,dd MMM yyyy HH:mm:ss");
long dateInMillis = 0;
try {
Date date = formatter.parse(srcDate);
dateInMillis = date.getTime();
return dateInMillis;
}
catch (java.text.ParseException e) {
e.printStackTrace();
}
return 0;
}