Here you can find the source of getLastDayOfYear(int year)
public static Date getLastDayOfYear(int year)
//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(); } }