Thank you.

Maybe I made a mistake when coding it with your algorithm, but it
seems that it does not always work.
As a reference, I'm using this website (in french):
http://www.calendrier-365.fr/calendrier-2010.html

And I found this script to work well: 
http://syn.ac/tech/19/get-the-weeknumber-with-javascript/
It is easy to transform into Java/GWT (but with all the deprecation
warnings around the Date object).

On 5 août, 23:13, ctasada <[email protected]> wrote:
> AFAIK the only way is calculating it yourself
>
>         public static int calendarWeekIso(final Date inputDate) {
>
>                 int thursdayDay = 4 + firstDayOfWeek;
>
>                 Date thisThursday = new Date(inputDate.getYear(),
> inputDate.getMonth(),
>                                 inputDate.getDate() - weekday(inputDate) + 
> thursdayDay);
>
>                 Date firstThursdayOfYear = new Date(thisThursday.getYear(), 
> 0, 1);
>
>                 while (weekday(firstThursdayOfYear) != thursdayDay) {
>                         
> firstThursdayOfYear.setDate(firstThursdayOfYear.getDate() + 1);
>                 }
>
>                 Date firstMondayOfYear = new 
> Date(firstThursdayOfYear.getYear(), 0,
>                                 firstThursdayOfYear.getDate() - 3);
>
>                 Long cw = (thisThursday.getTime() - 
> firstMondayOfYear.getTime())
>                                 / ONE_DAY / DAYS_IN_A_WEEK + 1;
>
>                 return cw.intValue();
>         }
>
> On 5 ago, 17:15, Glimpse <[email protected]> wrote:
>
>
>
> > Hello all,
>
> > I'd like to know if there is an easy way to get the week number from a
> > Date object. In pure Java, the Calendar class does the trick via a
> > call to get(Calendar.WEEK_OF_YEAR); but the Calendar class is not
> > available in GWT.
>
> > Any idea?

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to