Changeset 1428

Show
Ignore:
Timestamp:
23/12/09 10:50:01 (3 months ago)
Author:
bruno
Message:

Fix bug in CalendarUtil?.getCalendar(week, year).
Remove some unnecessary "Calendar." prefixes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tupper/trunk/tupper-site/src/main/java/org/kauriproject/tupper/resource/CalendarUtil.java

    r1427 r1428  
    2121    public static int getNumberOfWeeksInYear(int year) { 
    2222        Calendar calendar = getCalendar(); 
    23         calendar.set(Calendar.DAY_OF_YEAR, 1); 
    24         calendar.set(Calendar.YEAR, year); 
    25         return calendar.getActualMaximum(Calendar.WEEK_OF_YEAR); 
     23        calendar.set(DAY_OF_YEAR, 1); 
     24        calendar.set(YEAR, year); 
     25        return calendar.getActualMaximum(WEEK_OF_YEAR); 
    2626    } 
    2727 
    2828    public static Calendar getCalendar(int week, int year) { 
    2929        Calendar calendar = getCalendar(); 
    30         calendar.set(Calendar.YEAR, year); 
    31         calendar.set(Calendar.WEEK_OF_YEAR, week); 
     30        calendar.set(YEAR, year); 
     31        calendar.set(WEEK_OF_YEAR, week); 
    3232 
    3333        // For the first and last week of the year, we have to be careful 
     
    3838        // year that corresponds to the week number. 
    3939        if (week == 1) { 
    40             calendar.set(Calendar.DAY_OF_YEAR, 1); 
     40            calendar.set(DAY_OF_WEEK, SATURDAY); 
    4141        } else { 
    4242            // we don't check explictly for the last week of the year, 
    4343            // but this covers it 
    44             calendar.set(Calendar.DAY_OF_WEEK, calendar.getFirstDayOfWeek()); 
     44            calendar.set(DAY_OF_WEEK, calendar.getFirstDayOfWeek()); 
    4545        } 
    4646        return calendar; 
     
    7979        // Go via calendar to do a lenient interpretation of the values 
    8080 
    81         Calendar startCal = CalendarUtil.getCalendar(startWeek, startYear); 
     81        Calendar startCal = getCalendar(startWeek, startYear); 
    8282        startWeek = startCal.get(WEEK_OF_YEAR); 
    8383        startYear = startCal.get(YEAR); 
    8484 
    85         Calendar endCal = CalendarUtil.getCalendar(endWeek, endYear); 
     85        Calendar endCal = getCalendar(endWeek, endYear); 
    8686        endWeek = endCal.get(WEEK_OF_YEAR); 
    8787        endYear = endCal.get(YEAR);