private static boolean getConstantHoliday(final Date date){
int monthDay = Integer.parseInt(DateUtil.getMonth(date)+""+DateUtil.getDay(date));
switch(monthDay){
case 11 :
return true;
case 51:
return true;
case 101:
return true;
case 102:
return true;
case 103:
return true;
case 104:
return true;
case 105:
return true;
default:
return false;
}
} 以上代码是我写的一个小方法,但是总是感觉代码写的不简洁,不知道个位大侠有没有谁能帮我简化一下,谢谢,分数是不会少了。
int monthDay = Integer.parseInt(DateUtil.getMonth(date)+""+DateUtil.getDay(date));
switch(monthDay){
case 11 :
return true;
case 51:
return true;
case 101:
return true;
case 102:
return true;
case 103:
return true;
case 104:
return true;
case 105:
return true;
default:
return false;
}
} 以上代码是我写的一个小方法,但是总是感觉代码写的不简洁,不知道个位大侠有没有谁能帮我简化一下,谢谢,分数是不会少了。
switch(monthDay){
case 11 :
case 51:
case 101:
case 102:
case 103:
case 104:
case 105:
return true;
default:
return false;
}
int monthDay = Integer.parseInt(DateUtil.getMonth(date)+""+DateUtil.getDay(date));
return 11 == monthDay || 51 == monthDay || 101 == monthDay ||102 == monthDay
|| 103 == monthDay || 104 == monthDay || 105 == monthDay;
}这是我自己改的,不知道有没有更好的。
for (int i = 0; i < a.length; i++) {
if (a[i] == monthDay) {
return true;
}
}
return false;