Wednesday, September 28, 2005

Week of the year calculation in Oracle and Java

I was kinda surprised when I discovered that Oracle and Java calculated weeks of year differently - Java taking into account the day of week it is, whereas Oracle concerned only with the date.

For example, if the first day of the year is a Friday, Java will fetch Jan 1 to be week 1, Jan 2 too as weekday 1 and Jan 3 as weekday 2 (yeah it could also depend on what day you set as the start of a week). Oracle does not seem to care what day the first day of the year was. It just picks the first 7 days of the year as the first week of the year, next 7 days as the second week, and so on..

Now I know why they need a bridge to connect!

No comments: