import java.text.DateFormat; /** * No.188 HAPPY DAY */ public class HappyDay { public static void main(String[] args) { final int year = 2015; int tensPlace = 0; int onePlace = 0; int resNum = 0; String str = ""; DateFormat format = DateFormat.getDateInstance(); format.setLenient(false); for (int day=1; day<=31; day++) { tensPlace = (int) Math.floor(day / 10); onePlace = day % 10; str = year + "/" + (tensPlace + onePlace) + "/" + tensPlace + "" + onePlace; try { format.parse(str); resNum++; } catch (Exception ex) { // 何もしない } } System.out.println(resNum); } }