Detect months with 31 days

前端 未结 19 1609
南旧
南旧 2020-12-18 01:53

Is there an analogous form of the following code:

if(month == 4,6,9,11)
{
  do something;
}

Or must it be:

if(month == 4 ||         


        
19条回答
  •  伪装坚强ぢ
    2020-12-18 02:39

    Move to first of next month and subtract a day.

    Calendar  cal=Calendar.getInstance();
    cal.add(Calendar.MONTH,1);
    cal.set(Calendar.DAY_OF_MONTH,1);
    cal.add(Calendar.DATE, -1);
    

提交回复
热议问题