Here you can find the source of getYearEnd(Date date)
public static Date getYearEnd(Date date)
//package com.java2s; import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date getYearEnd(Date date) { String newDateStr = FormatDate(date, "yyyy") + "-12-31"; return stringToDateShort(newDateStr); }/* w w w. j a va2 s .c o m*/ public static String FormatDate(Date date, String sf) { if (date == null) return ""; SimpleDateFormat dateformat = new SimpleDateFormat(sf); return dateformat.format(date); } public static Date stringToDateShort(String dateString) { String sf = "yyyy-MM-dd"; Date dt = stringToDate(dateString, sf); return dt; } public static Date stringToDate(String dateString) { String sf = "yyyy-MM-dd HH:mm:ss"; Date dt = stringToDate(dateString, sf); return dt; } public static Date stringToDate(String dateString, String sf) { ParsePosition pos = new ParsePosition(0); SimpleDateFormat sdf = new SimpleDateFormat(sf); Date dt = sdf.parse(dateString, pos); return dt; } }