Java Day End endOfYear(Date referenceDate, TimeZone timeZone)

Here you can find the source of endOfYear(Date referenceDate, TimeZone timeZone)

Description

Calcuate the date at the end of the year from the given date.

License

Open Source License

Parameter

Parameter Description
referenceDate The given date.

Return

The calendar at the end of the year.

Declaration

public static Calendar endOfYear(Date referenceDate, TimeZone timeZone) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    /**/*from w  w w. jav  a 2s. c  o  m*/
     * Calcuate the date at the end of the year from the
     * given date.
     * 
     * @param referenceDate The given date.
     * @return The calendar at the end of the year.
     */
    public static Calendar endOfYear(Date referenceDate, TimeZone timeZone) {
        Calendar c1 = Calendar.getInstance(timeZone);
        c1.setTime(referenceDate);

        Calendar c2 = Calendar.getInstance();
        c2.clear();
        c2.set(c1.get(Calendar.YEAR) + 1, 0, 1);
        c2.setTimeZone(timeZone);

        return c2;
    }
}

Related

  1. endOfDay(final Date date)
  2. endOfDay(final Date date)
  3. endOfDayDate(Date date)
  4. endOfDayInMillis(long date)
  5. endOfTheMonth(java.util.Date date, Locale locale)
  6. fillBetweenDays(Date from, Date to)
  7. getAgeInDays(Date startDate, Date endDate)
  8. getApartDate(Date startDate, Date endDate)
  9. getBetweenDays(String strFromDate, String strToDate)