Date: Mon, 29 May 2006 17:20:19 +0200 From: Heiko Weber <java@wecos.de> To: freebsd-java@freebsd.org Subject: Calendar Question - maybe bug ? Message-ID: <200605291720.19793.java@wecos.de>
next in thread | raw e-mail | index | archive | help
Hi ! I've a problem with GregorianCalendar, which returns different weeks (in year) on FreeBSD 6.1, java version is # java -version Java HotSpot(TM) Server VM (build 1.5.0-p2-heiko_03_jan_2006_23_51, mixed mode) Test program (A.java): import java.util.Calendar; import java.util.GregorianCalendar; public class A { public static int weeksInYear(int year) { Calendar cal = GregorianCalendar.getInstance(); cal.set(year, 11, 31); return cal.get(Calendar.WEEK_OF_YEAR) == 53 ? 53 : 52; } public static void main(String args[]) { for (int i = 1990; i <= 2006; i++) System.out.println("Weeks in Year " + i + " = " + weeksInYear(i)); } } Output on a Linux or Windows JRE is: Weeks in Year 1990 = 52 Weeks in Year 1991 = 52 Weeks in Year 1992 = 53 Weeks in Year 1993 = 52 Weeks in Year 1994 = 52 Weeks in Year 1995 = 52 Weeks in Year 1996 = 52 Weeks in Year 1997 = 52 Weeks in Year 1998 = 53 Weeks in Year 1999 = 52 Weeks in Year 2000 = 52 Weeks in Year 2001 = 52 Weeks in Year 2002 = 52 Weeks in Year 2003 = 52 Weeks in Year 2004 = 53 Weeks in Year 2005 = 52 Weeks in Year 2006 = 52 Output on FreeBSD is: Weeks in Year 1990 = 52 Weeks in Year 1991 = 52 Weeks in Year 1992 = 52 Weeks in Year 1993 = 52 Weeks in Year 1994 = 53 Weeks in Year 1995 = 52 Weeks in Year 1996 = 52 Weeks in Year 1997 = 52 Weeks in Year 1998 = 52 Weeks in Year 1999 = 52 Weeks in Year 2000 = 52 Weeks in Year 2001 = 52 Weeks in Year 2002 = 52 Weeks in Year 2003 = 52 Weeks in Year 2004 = 52 Weeks in Year 2005 = 53 Weeks in Year 2006 = 52 Is this my fault or would it help to update the FreeBSD JRE ? Or is the java-Calendar-System build up on some local (changeable) settings ? Thanks for any help or hint. Heiko
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200605291720.19793.java>