I need to walk through a time slot to set up a schedule grid. Example: 8:00 AM to 10:00 AM, adding 30 minutes. Forming a grid like this: 8 o'clock 08:30 09:00 09:30 10:00
I'm trying like this:
GregorianCalendar gc = new GregorianCalendar();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
Date hInicial = null, hFinal = null;
try {
hInicial = sdf.parse("08:00");
hFinal = sdf.parse("10:00");
} catch (ParseException e) {
e.printStackTrace();
}
GregorianCalendar inicio = new GregorianCalendar();
inicio.setTime(hInicial);
GregorianCalendar fim = new GregorianCalendar();
fim.setTime(hFinal);
gc.setTime(hInicial);
while(!inicio.after(fim)) {
gc.add(Calendar.MINUTE, 30);
}
The system is in infinite loop.
Thank you in advance.