Java Year Day getLastDayOfYear(int year)

Here you can find the source of getLastDayOfYear(int year)

Description

get Last Day Of Year

License

LGPL

Declaration

public static Date getLastDayOfYear(int year) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.util.Calendar;
import java.util.Date;

public class Main {

    public static Date getLastDayOfYear(int year) {
        return getLastDayOfQuarter(year, 4);
    }/*from   w w w. j  a  v a2s.  c o m*/

    public static Date getLastDayOfQuarter(int year, int quarter) {
        int month = 0;
        if (quarter > 4) {
            return null;
        } else {
            month = quarter * 3;
        }
        return getLastDayOfMonth(year, month);
    }

    public static Date getLastDayOfMonth(int year, int month) {
        Calendar c = Calendar.getInstance();
        c.set(Calendar.YEAR, year);
        c.set(Calendar.MONTH, month - 1);
        c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH));
        c.set(Calendar.HOUR, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        c.set(Calendar.MILLISECOND, 0);
        return c.getTime();
    }
}

Related

  1. getCurrYearFirstDay(int year)
  2. getFirstDay4CurrentYear()
  3. getFirstDayOfThisYear()
  4. getLastDayOfTheYear(int year)
  5. getLastDayOfYear(int year)
  6. getTodayYear()
  7. getWeekNumOfYearDay(String strDate)
  8. getYearFirstDay(String date)
  9. getYearLastDay(String dateString)