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.




