Sunday 12 August 2018

android - How to display time adding 30mins from current time

I just want it to be displayed from current time adding 30mins till day ends
Ex-Today time is 09:46AM
It should display like 10:00AM,10:30AM,11:00AM....11:30PM for that particular date.

But here in my code its displaying from 00:00...23:30 for whole day.
Here is my code:



SimpleDateFormat df = new SimpleDateFormat("HH:mm");
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
int startDate = cal.get(Calendar.DATE);
while (cal.get(Calendar.DATE) == startDate) {

Log.d("time","currenttime"+cal.getTime());
cal.add(Calendar.MINUTE, 30);
}

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...