Вот мой код:
Код: Выделить всё
public class dateCheck {
public static void main(String[] args) {
String weekday="Sunday";
int year=2017;
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DATE, 01);
cal.set(Calendar.MONTH, Calendar.JANUARY);
cal.set(Calendar.YEAR, year);
cal.set(Calendar.DAY_OF_MONTH, 1);
Date firstDayOfMonth = cal.getTime();
DateFormat sdf = new SimpleDateFormat("EEEEEEEE");
System.out.println("First Day of Month: " + sdf.format(firstDayOfMonth));
if(weekday.equals(sdf.format(firstDayOfMonth))){
System.out.println("This day falls on the first of the month");
}
else
System.out.println("This day does not fall on the first of the month");
}
}
Подробнее здесь: https://stackoverflow.com/questions/441 ... ified-year