Java Week Day lastDayOfWeek(int year, int month)

Here you can find the source of lastDayOfWeek(int year, int month)

Description

last Day Of Week

License

Open Source License

Declaration

@SuppressWarnings("deprecation")
public static int lastDayOfWeek(int year, int month) 

Method Source Code

//package com.java2s;

import java.util.*;

public class Main {

    @SuppressWarnings("deprecation")
    public static int lastDayOfWeek(int year, int month) {
        Date lastDate = new Date(year - 1900, month - 1, days(year, month));
        return lastDate.getDay();
    }/*w  w w.  ja v a  2s .  com*/

    public static int days(int year, int month) {
        int total = 30;
        switch (month) {
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            total = 31;
            break;
        case 2:
            if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
                total = 29;
            else
                total = 28;
            break;
        default:
            break;
        }
        return total;
    }
}

Related

  1. isFirseDayOfCurrentWeek(Date date)
  2. isoDayOfWeek(int javaDayOfWeek)
  3. isWeekday(String dateStr, String format)
  4. isWeekendDay(String strDay, DateFormat dateFormatter)
  5. isWeekendToday()
  6. nextDayAndHour(int dayOfTheWeek, int hour)
  7. nextTwoWeeksFromToday()
  8. nextWeekday(int weekday, int hour, int minute, int second)
  9. parseToEntireWeekCaption(String startDay, String pattern)