java - How to add minutes to a date inside a loop -


i have date want increase 15 minutes while condition met. problem adds 15 minutes once. output per screen similar operation dates.

int = 10; while (i <= 100){   = + 15;   system.out.println(i); }  screen output  10 25 40 55 70 85 100  code dates following  while(hour < hourend){   hour = new date();  hour = date.getdate();  calendar cal = calendar.getinstance();  cal.settime(hour);  cal.add(calendar.minute, 15);  hour = cal.gettime(); }  

my problem adds 15 minutes once.

you'll need create date before loop begins.otherwise, create new date @ each iteration.

hour = new date(); calendar cal = calendar.getinstance();  while(hour < hourend){    cal.settime(hour);    cal.add(calendar.minute, 15);    hour = cal.gettime(); }  

Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -