0
I need to go through an hour interval to assemble a grid with schedules. Example: range 08:00 to 10:00, adding 30 minutes. Forming a grid like this: 08:00 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 loops infinitely.
Thank you in advance.