java - how to modify a calendar -


i need insert 2 columns called: beginhour , endhour dates ans times in calendar type.

i have method generates beginhour, modify endhour. call dao method insert them in table.

the problem find last modification of variable 'cal' 2 columns.

for example if beginhour 2014-03-24 15:23:10 endhour should 2014-03-24 15:28:20 in table find endhour : 2014-03-24 15:28:20 2 columns.

calendar cal = mock.randombeginhour();         consoapp.setbeginhour(cal);       cal.add(calendar.minute, +5);     cal.add(calendar.second, +10);         consoapp.setendhour(cal);         dao.addconsoappel(consoapp) 

you're using same calendar object reference both beginhour , endhour. create 2 different calendars instead. can create calendar instance using calendar#getinstance() , assign time in first calendar set start time other. in code:

calendar cal = mock.randombeginhour(); consoapp.setbeginhour(cal); calendar cal2 = calendar.getinstance(); cal2.settime(cal.gettime()); cal2.add(calendar.minute, +5); cal2.add(calendar.second, +10); consoapp.setendhour(cal2); dao.addconsoappel(consoapp); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -