Good day.
I am trying to create a quiz answer form where there is a time limit.
The timelimit is defined by the teacher in hours and minutes. It is then added to the date-time where the student has taken the quiz.
int HOUR = getHour();
int MIN = getMinute();
String START_TIME = getTimestart();
SimpleDateFormat FORMAT = new SimpleDateFormat(pattern, java.util.Locale.getDefault());
Date parsed_START = FORMAT.parse(START_TIME );
Calendar gc = new GregorianCalendar();
gc.setTime(parsed_START);
gc.add(Calendar.HOUR, HOUR);
gc.add(Calendar.MINUTE, MIN);
Date TIMESTOP = gc.getTime();
What I want to do is compare the device's current time to TIMESTOP. If the two are equal or the current device's Datetime is greater than TIMESTOP then the quiz will submit itself regardless of the progress of the student.
I have tried so many ways to get the devices time, however most of it outputs the wrong time, or the date formatter I'm using does not work. It always say String cannot be used for date. But I have seen so many examples like this : https://www.mkyong.com/java/java-how-to-get-current-date-time-date-and-calender/ yet their SimpleDateFormat works. This is getting frustrating. So I appreciate any kind of help thank you.