Java Day End getEndSixMonthly(Date startDate)

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

Description

get End Six Monthly

License

Open Source License

Declaration

public static Date getEndSixMonthly(Date startDate) 

Method Source Code


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

public class Main {
    public static Date getEndSixMonthly(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.JUNE) {
            result.set(Calendar.MONTH, Calendar.JUNE);
            result.set(Calendar.DATE, result.getActualMaximum(Calendar.DATE));
            result.set(Calendar.YEAR, calendar.get(Calendar.YEAR));
        } else {/*w w  w . j  ava  2s.co m*/
            result.set(Calendar.MONTH, Calendar.DECEMBER);
            result.set(Calendar.DATE, result.getActualMaximum(Calendar.DATE));
            result.set(Calendar.YEAR, calendar.get(Calendar.YEAR));
        }
        return result.getTime();
    }
}

Related

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