Java Day End getEndQuaterly(Date startDate)

Here you can find the source of getEndQuaterly(Date startDate)

Description

get End Quaterly

License

Open Source License

Declaration

public static Date getEndQuaterly(Date startDate) 

Method Source Code


//package com.java2s;
import java.util.Calendar;
import java.util.Date;

public class Main {
    public static Date getEndQuaterly(Date startDate) {
        Calendar result = Calendar.getInstance();

        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.YEAR, startDate.getYear() + 1900);
        calendar.set(Calendar.MONTH, startDate.getMonth());
        calendar.set(Calendar.DATE, startDate.getDate());

        if (calendar.get(Calendar.MONTH) <= Calendar.MARCH) {
            result.set(Calendar.MONTH, Calendar.MARCH);
            result.set(Calendar.DATE, result.getActualMaximum(Calendar.DATE));
            result.set(Calendar.YEAR, calendar.get(Calendar.YEAR));

        } else if (calendar.get(Calendar.MONTH) <= Calendar.JUNE) {
            result.set(Calendar.MONTH, Calendar.JUNE);
            result.set(Calendar.DATE, result.getActualMaximum(Calendar.DATE));
            result.set(Calendar.YEAR, calendar.get(Calendar.YEAR));

        } else if (calendar.get(Calendar.MONTH) <= Calendar.SEPTEMBER) {
            result.set(Calendar.MONTH, Calendar.SEPTEMBER);
            result.set(Calendar.DATE, result.getActualMaximum(Calendar.DATE));
            result.set(Calendar.YEAR, calendar.get(Calendar.YEAR));

        } else {/* w ww. jav a  2 s.  c  o  m*/
            result.set(Calendar.MONTH, Calendar.DECEMBER);
            result.set(Calendar.DATE, calendar.getMaximum(Calendar.DATE));
            result.set(Calendar.YEAR, calendar.get(Calendar.YEAR));
        }

        return result.getTime();
    }
}

Related

  1. getEndOfDay(final Date date, final TimeZone timeZone)
  2. getEndOfDay(Long date)
  3. getEndOfHour(Date day)
  4. getEndOfTheDate(Date date)
  5. getEndOfYear(Date dt)
  6. getEndSixMonthly(Date startDate)
  7. getEndTimeOfDay(Date date)
  8. getEndTimeOfDayOrNow(Date date)
  9. getKalenderWoche(final Date date, final Locale locale)