java - How to replace getDate() from the type Date which is deprecated? -
i have existing program have correct . contains these lines :
date startdate = new date(); int day = startdate.getdate() - 1;
but getdate() type date deprecated have change using calender. tried :
calendar startdate = calendar.getinstance(); startdate.add(calendar.date, -1); int day= startdate.gettime();
but results following error :
type mismatch: cannot convert date int
if want day in month use this:
int day= startdate.get(calendar.day_of_month);
if want day in week use this:
int day= startdate.get(calendar.day_of_week);
also careful day of week, because day 0 sunday not monday.
field number , set indicating day of week. field takes values sunday, monday, tuesday, wednesday, thursday, friday, , saturday.
Comments
Post a Comment