Here you can find the source of getYearOfWeek(Date date)
public static Integer getYearOfWeek(Date date)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static int FIRST_DAY_OF_WEEK = Calendar.MONDAY; public static Integer getYearOfWeek(Date date) { Date sunday = getSundayOfWeek(date); return getYear(sunday); }//ww w . j av a2s. c o m public static Date getSundayOfWeek(Date date) { Calendar sunday = getCalendar(); sunday.setTime(date); sunday.setFirstDayOfWeek(FIRST_DAY_OF_WEEK); sunday.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); return sunday.getTime(); } public static Date getSundayOfWeek(int year, int weekOfYear) { Calendar sunday = getCalendar(); sunday.set(Calendar.YEAR, year); sunday.set(Calendar.WEEK_OF_YEAR, weekOfYear + 1); sunday.setFirstDayOfWeek(FIRST_DAY_OF_WEEK); sunday.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); return sunday.getTime(); } public static Integer getYear(Date date) { Calendar c = getCalendar(); c.setTime(date); return c.get(Calendar.YEAR); } private static Calendar getCalendar() { Calendar c = Calendar.getInstance(); c.setFirstDayOfWeek(FIRST_DAY_OF_WEEK); return c; } }