The bug I referenced is definitely still present up to at least Java
1.6.0_10 .  I get "200901" when I run this code on my local Sun Java
1.6.0_10 JDK with a timezone of CST for 1262000152901L.

The bug is that it's returning a value of "200901" instead of "201001" for
time points that occur in 2009 but are in the "first week of 2010", which is
defined as:

"Week 1 for a year is the earliest seven day period starting on
getFirstDayOfWeek() that contains at least getMinimalDaysInFirstWeek() days
from that year."

This blog post has a better description of the JRE bug:

http://bmcardoso.blogspot.com/2008/01/javautilgregoriancalendar.html

On Mon, Dec 28, 2009 at 3:57 PM, Raphael André Bauer <
[email protected]> wrote:

> On Mon, Dec 28, 2009 at 6:04 PM, Don Schwarz <[email protected]> wrote:
> > I suspect that WEEK_OF_YEAR and YEAR do not generally behave the way you
> > want.  See this bug for more details:
> > http://bugs.sun.com/view_bug.do?bug_id=4267450
> > As for why this works for you locally and not when deployed to App
> Engine, I
> > don't have a satisfactory answer.  Have you verified that the timezones
> are
> > the same (by adding "zzz" to your format string)
>
> Hi Don,
>
>
> thanks for the superfast reply. I tried it again setting the locale
> and the timezone explicitly (and also using explicitly the
> GregorianCalendar).
>
> ==snippp
> Calendar calendar = GregorianCalendar.getInstance(
>    TimeZone.getTimeZone("MEZ"), Locale.GERMAN);
> calendar.setTimeInMillis(millisecs);
> DateFormat formatter = new SimpleDateFormat("yyyyww");
>
> return formatter.format(calendar.getTime());
>
> == snapp
>
> however the error is still there. Using the timestamp of now
> (1262000152901L) my local machine tells me:
> "200953"  what is correct, but App Engine returns the wrong "200901".
>
> Hmm. What puzzles me is why my local machine can calculate the "ww".
> Therefore I am still not too sure if the bug you mentioned (4267450)
> from sun still applies to my SDK version 1.6 - because my 1.6 series
> can calculate the week without any problems.
>
> The next question then is: What SDK is the App Engine using? I bet
> it's not the SDK from Sun, but Open SDK or a derivate. And if that's
> the case this might be a bug...
>
>
> I think I am going to implement the "ww" myself to circumvent the App
> Engine behavior and file a bug... Not nice, but I need the
> functionality...
>
>
> Raphael
> >
> > On Mon, Dec 28, 2009 at 5:54 AM, Raphael André Bauer
> > <[email protected]> wrote:
> >>
> >> Hi,
> >>
> >>
> >> I am currently using this code to calculate the week of the year:
> >>
> >>
> >> ===snip
> >> Calendar calendar = Calendar.getInstance();
> >> calendar.setTimeInMillis(millisecs);
> >> DateFormat formatter = new SimpleDateFormat("yyyyww");
> >>
> >> String timeStamp =  formatter.format(calendar.getTime());
> >> ===snap
> >>
> >> Using the timestamp of now (1262000152901L) my local machine tells me:
> >> "200953"  what is correct.
> >>
> >> However, if I execute the very same code on the App Engine I get week
> >> "200901" (!) what is strange, because the year is correct, but the
> >> week is not...
> >>
> >>
> >> Any ideas?
> >>
> >> Thanks a lot!
> >>
> >>
> >>
> >> Raphael
> >>
> >> --
> >>
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Google App Engine for Java" group.
> >> To post to this group, send email to
> >> [email protected].
> >> To unsubscribe from this group, send email to
> >> [email protected]<google-appengine-java%[email protected]>
> .
> >> For more options, visit this group at
> >> http://groups.google.com/group/google-appengine-java?hl=en.
> >>
> >>
> >
> > --
> >
> > You received this message because you are subscribed to the Google Groups
> > "Google App Engine for Java" group.
> > To post to this group, send email to
> [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<google-appengine-java%[email protected]>
> .
> > For more options, visit this group at
> > http://groups.google.com/group/google-appengine-java?hl=en.
> >
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-appengine-java%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" 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-appengine-java?hl=en.


Reply via email to