@ SuppressWarnings ( "deprecation" ) private Date getWeekOne ( int year ) { GregorianCalendar weekOne = new GregorianCalendar ( ) ; weekOne . setFirstDayOfWeek ( getFirstDayOfWeek ( ) ) ; weekOne . setMinimalDaysInFirstWeek ( getMinimalDaysInFirstWeek ( ) ) ; weekOne . setTime ( new Date ( year , 0 , 1 ) ) ; // can we use the week of 1/1/year as week one? int dow = weekOne . get ( DAY_OF_WEEK ) ; if ( dow < weekOne . getFirstDayOfWeek ( ) ) dow += 7 ; int eow = weekOne . getFirstDayOfWeek ( ) + 7 ; if ( ( eow - dow ) < weekOne . getMinimalDaysInFirstWeek ( ) ) { // nope, week one is the following week weekOne . add ( DATE , 7 ) ; } weekOne . set ( DAY_OF_WEEK , weekOne . getFirstDayOfWeek ( ) ) ; return weekOne . getTime ( ) ; }
Gets the date of the first week for the specified year .