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