このコードを使用してみてください
private void displayTimeSlots() {
String timeValue = "T00:00:4.896+05:30";
SimpleDateFormat sdf = new SimpleDateFormat("'T'hh:mm:ss.SSS");
try {
Calendar startCalendar = Calendar.getInstance();
startCalendar.setTime(sdf.parse(timeValue));
if (startCalendar.get(Calendar.MINUTE) < 30) {
startCalendar.set(Calendar.MINUTE, 30);
} else {
startCalendar.add(Calendar.MINUTE, 30); // overstep hour and clear minutes
startCalendar.clear(Calendar.MINUTE);
}
Calendar endCalendar = Calendar.getInstance();
endCalendar.setTime(startCalendar.getTime());
// if you want dates for whole next day, uncomment next line
//endCalendar.add(Calendar.DAY_OF_YEAR, 1);
endCalendar.add(Calendar.HOUR_OF_DAY, 24 - startCalendar.get(Calendar.HOUR_OF_DAY));
endCalendar.clear(Calendar.MINUTE);
endCalendar.clear(Calendar.SECOND);
endCalendar.clear(Calendar.MILLISECOND);
SimpleDateFormat slotTime = new SimpleDateFormat("hh:mm a");
while (endCalendar.after(startCalendar)) {
startCalendar.add(Calendar.MINUTE, 30);
String Timeslots = slotTime.format(startCalendar.getTime());
Log.e("DATE", Timeslots);
}
} catch (ParseException e) {
// date in wrong format
}
}