Here you can find the source of setYear(Date date, int year)
public static Date setYear(Date date, int year)
//package com.java2s; //License from project: LGPL import java.util.Calendar; import java.util.Date; public class Main { public static Date setYear(Date date, int year) { return setField(date, Calendar.YEAR, year); }/*from ww w.j a va 2 s . c o m*/ public static Date setField(Date date, int field, int value) { Date result = date; if (date != null) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.set(field, value); result = calendar.getTime(); } return result; } }