R
ruds
hi,
I want to get the last day of previous month.
i have tried using GregorianCalendar;
Calendar cal = new GregorianCalendar(year1, lastmonth, 1);
// Get the number of days in that month
cal.set(Calendar.MONTH, lastmonth);
//cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH)-1);
int days = cal.getActualMaximum(cal.DAY_OF_MONTH);
System.out.println("max = "+days);
String
lastdate=String.valueOf(cal.getActualMaximum(cal.DAY_OF_MONTH));
but still I get the lastdate for current month (31) and not for last
month(30).
Please tell me what to do?
I want to get the last day of previous month.
i have tried using GregorianCalendar;
Calendar cal = new GregorianCalendar(year1, lastmonth, 1);
// Get the number of days in that month
cal.set(Calendar.MONTH, lastmonth);
//cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH)-1);
int days = cal.getActualMaximum(cal.DAY_OF_MONTH);
System.out.println("max = "+days);
String
lastdate=String.valueOf(cal.getActualMaximum(cal.DAY_OF_MONTH));
but still I get the lastdate for current month (31) and not for last
month(30).
Please tell me what to do?