Here you can find the source of getHalfYearEndDate(Date date)
public static Date getHalfYearEndDate(Date date)
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date getHalfYearEndDate(Date date) { try {/*ww w .j a va 2 s .co m*/ String strDate = ""; SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); String format2 = format.format(date); String[] split = format2.split("-"); String year = split[0]; String month = split[1]; int parseInt = Integer.parseInt(month); if (parseInt <= 6) { strDate = year + "-" + "06" + "-" + "30"; } else { strDate = year + "-" + "12" + "-" + "31"; } Date parse = format.parse(strDate); return parse; } catch (ParseException e) { e.printStackTrace(); return null; } } }