Here you can find the source of getEndDateOfCurrentSemester()
private static Date getEndDateOfCurrentSemester()
//package com.java2s; //License from project: Open Source License import java.util.Date; import java.util.Calendar; public class Main { private static Date getEndDateOfCurrentSemester() { Calendar cal = Calendar.getInstance(); int month = cal.get(Calendar.MONTH); int year = cal.get(Calendar.YEAR); if (month >= 9 && month <= 2) { // one second before Apr 01 00:00:00 CEST year cal.set(year, Calendar.APRIL, 1, 0, 0, 0); cal.add(Calendar.SECOND, -1); return cal.getTime(); } else {//ww w.j av a 2s. co m // one second before Oct 01 00:00:00 CEST year cal.set(year, Calendar.OCTOBER, 1, 0, 0, 0); cal.add(Calendar.SECOND, -1); return cal.getTime(); } } }