Detect months with 31 days

前端 未结 19 1617
南旧
南旧 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条回答
  •  萌比男神i
    2020-12-18 02:30

    Don't do any specific checks. Try and convert to a valid date - if it throws an exception, report invalid date. After all you also need to check for day greater than 28 (or is it 29?) if the month is February.

提交回复
热议问题