CalendarUtils { public static int weekOfYear(final Date date) { return fromDateToCalendar(date).get(Calendar.WEEK_OF_YEAR); } private  CalendarUtils(); static Calendar fromDateToCalendar(final Date date); static int weekDay(final Date date); static int month(final Date date); static int weekOfYear(final Date date); static int day(final Date date); static int dayOfYear(final Date date); static int year(final Date date); static boolean isLeapYear(final Date date); static boolean isAM(final Date date); static boolean isPM(final Date date); static int hour12(final Date date); static int hour24(final Date date); static int minute(final Date date); static int second(final Date date); static int millisecond(final Date date);  }
@Test public void testWeekOfYear() throws Exception { final Date week1Date = date(2014, 12, 29); final Date week2Date = date(2015, 1, 5); final Date week52Date = date(2015, 12, 27); final Date week53Date = date(2016, 1, 3); final int week1 = CalendarUtils.weekOfYear(week1Date); final int week2 = CalendarUtils.weekOfYear(week2Date); final int week52 = CalendarUtils.weekOfYear(week52Date); final int week53 = CalendarUtils.weekOfYear(week53Date); assertThat(week1, is(1)); assertThat(week2, is(2)); assertThat(week52, is(52)); assertThat(week53, is(53)); }