Java 比较两个日期的月份和日是否相同

public static int compare_monuthAndDay(String date1, String date2) {
		int month1 = Integer.parseInt(date1.substring(5, 7));
		int day1 = Integer.parseInt(date1.substring(8, 10));
		int month2 = Integer.parseInt(date2.substring(5, 7));
		int day2 = Integer.parseInt(date2.substring(8, 10));
		if (month1 == month2 && day1 == day2) {
			return 0;
		} else {
			return 1;
		}
	}
 

你可能感兴趣的:(Java)