I Hate Computers, Part Sixty Bazillion

Ya know, every time I think “Wow, Java’s pretty damn nice” I run up against something so egregiously stupid that it makes me want to dash my brains out with a brick. For example:

The class java.lang.Double has a constructor which takes a String object.

So you’d expect something like
Double d = new Double("99,999.00");

to actually work, at least with a US locale. You’d be wrong. That throws a NumberFormatException. If you do this:
Double d = new Double("99999.00");

it actually works. Because you’d never, ever, in a million years want to turn a string that contains commas into a Double.

And doing :
Double d = (Double) NumberFormat.getInstance().parse("99,999.00");

throws a ClassCastException, even though NumberFormat.parse() returns a Number, and Double is derived from Number. Though to be fair, it may have thrown a NumberFormatException and gotten ignored since java won’t let you just let an exception propagate up to mian() and asplose there.

I’m sure the answer is something that does what I want but involves ten classes and 40 intermediate objects, and it will actually make some sort of sense when I actually find out what it is. But for christ sake, atod() just works. Not well, I’ll grant you, but it works and it’s obvious.

I need to find a Sun engineer and kick it in the nuts.

One Response to “I Hate Computers, Part Sixty Bazillion”

  1. Marc says:

    Sounds like the plumber joke by Steve Martin. I cant relate. BTW didnt all these jobs get outsourced to India where they make $3 a day in real money?