java - SmartGwt: add days to date -
how add days date in smartgwt. found this question , found can use calendarutil.adddaystodate(datetoaddto, daystoaddtodateasinteger)); adddaystodate() static void. point of method can "add days date" if not return anything?
how use method? want this.
date newdate = datetoaddto + daystoaddtodate; here simplified version of code.
if (listgridrecord.getattribute("expirationdays") != null) { calendarutil.adddaystodate((date) enddate.getvalue(), integer.parseint(listgridrecord.getattribute("expirationdays"))); listgridrecord.setattribute("expirationdate", (date) enddate.getvalue()); } else { listgridrecord.setattributeasjavaobject("expirationdate", null); } here link javadocs
this method changes object passed parameter.
date date = new date(); long checkbeforechange = date.gettime(); calendarutil.adddaystodate(date, 1); long checkafterchange = date.gettime(); if(checkbeforechange != checkafterchange) window.alert("it works ;)"); your code should that:
if (listgridrecord.getattribute("expirationdays") != null) { date tmpdate = enddate.getvalue(); calendarutil.adddaystodate(tmpdate, integer.parseint(listgridrecord.getattribute("expirationdays"))); listgridrecord.setattribute("expirationdate", tmpdate); } else { listgridrecord.setattributeasjavaobject("expirationdate", null); } when doing (date) enddate.getvalue() copy of date object don't see change.
Comments
Post a Comment