• Home
  • About
  • Doom II
  • Flog
  • Inspiration

Java 1.5 Hilarity/Stupidity

Posted in Computing. on Monday, March 12th, 2007 by Derek
Mar 12

GlitchInTheMatrix.java

1
2
3
4
5
6
7
8
9
10
import java.util.GregorianCalendar;
 
public class GlitchInTheMatrix
{
	public static void main(String[] args)
	{
		GregorianCalendar date = new GregorianCalendar(2007, GregorianCalendar.DECEMBER, 31);
		System.out.println("" + date.get(GregorianCalendar.WEEK_OF_YEAR));
	}
}

The output? 1. Yes, it’s the first week of the year in December. Can I call the bug, “Titorus Pullo”?

So I wrote a wrapper class on top.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import java.util.GregorianCalendar;
 
public class NonRetardedJavaCalendar extends GregorianCalendar
{
	public NonRetardedJavaCalendar(int year, int month, int day)
	{
		super(year, month, day);
	}
	public int getWeek()
	{
		int week = get(Calendar.WEEK_OF_YEAR);
		if(getMonth() == DECEMBER && week == 1)
			week = 53;
		return week;
	}
}
  • Now Playing: Explosions in the Sky - Peel Session 2004 - 03 - With Tired Eyes, Tired Minds, Tired Souls, We Slept

Leave a Reply

CAPTCHA Image
Refresh Image
*

Derek MacDonald


  • Photo Stream
  • Categories
    • Australia
    • Computing
    • Film & TV
    • Food
    • Gaming
    • General
    • Music
    • Sports
    • Visual Art
  • Search






  • Home
  • About
  • Doom II
  • Flog
  • Inspiration

© Copyright Derek MacDonald. All rights reserved.
Designed by FTL Wordpress Themes brought to you by Smashing Magazine

Back to Top