如何在android中获取当月的天数

时间:2014-12-05 04:37:16

标签: android days

我想知道当前日期时间和年份的名称,并计算当月的天数

1 个答案:

答案 0 :(得分:3)

int iYear = 2000;
int iMonth = Calendar.January;
int iDay = 1;

// Create a calendar object and set year and month
Calendar mycal = new GregorianCalendar(iYear, iMonth, iDay);

// Get the number of days in that month
int daysInMonth = mycal.getActualMaximum(Calendar.DAY_OF_MONTH);