Created
August 17, 2015 06:03
-
-
Save masakid/b60d93e977ee8bbad9a8 to your computer and use it in GitHub Desktop.
LeapYearJudgeTest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LeapYearJudgeTest { | |
/** | |
* 閏年判定メソッド | |
* 閏年の定義 | |
* 1)西暦400で割り切れる年は閏年である | |
* 2)400で割り切れない、かつ100で割り切れる場合は閏年ではない | |
* 3)400で割り切れない、かつ100で割り切れない、かつ4で割り切れる年は閏年である | |
* 4)400で割り切れない、かつ100で割り切れない、かつ4で割り切れない場合は閏年ではない | |
* | |
* @param targetYear | |
* @return | |
*/ | |
protected static String judgeLeapYear(Integer targetYear){ | |
if(targetYear%400 == 0){ | |
//1 | |
return "閏年である"; | |
} else if(targetYear%100 == 0){ | |
//2 | |
return "閏年ではない"; | |
} else if(targetYear%4==0){ | |
//3 | |
return "閏年である"; | |
} else { | |
//4 | |
return "閏年ではない"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment