Is there a parser for Java numeric string literals that returns the requested Number sub-class?
Within Java code it is possible to have numeric literals that use a suffix to indicate the type of the literal, e.g. `1D`, `0.15F` or `5L` for a `double`, `float` and `long` respectively. There is also support for hexadecimal and octal representations and possibly a few other things that I have not mentioned.

I'd like something equivalent to the parser that is used by `javac` internally that would return `Number` objects.

[`NumberFormat.parse()`](http://docs.oracle.com/javase/6/docs/api/java/text/NumberFormat.html#parse%28java.lang.String%29), as implemented in [`DecimalFormat`](http://docs.oracle.com/javase/6/docs/api/java/text/DecimalFormat.html) only seems to produce `Double` and `Long` objects, with quite a few issues when some of the notations mentioned above are used.

Is there a parser in the standard class library of, say, Java 6 and onwards that is able to transparently parse such strings and return the proper sub-class of `Number`? 

Is there a parser for Java numeric string literals that returns the requested Number sub-class?
===

Within Java code it is possible to have numeric literals that use a suffix to indicate the type of the literal, e.g. `1D`, `0.15F` or `5L` for a `double`, `float` and `long` respectively. There is also support for hexadecimal and octal representations and possibly a few other things that I have not mentioned.

I'd like something equivalent to the parser that is used by `javac` internally that would return `Number` objects.

[`NumberFormat.parse()`](http://docs.oracle.com/javase/6/docs/api/java/text/NumberFormat.html#parse%28java.lang.String%29), as implemented in [`DecimalFormat`](http://docs.oracle.com/javase/6/docs/api/java/text/DecimalFormat.html) only seems to produce `Double` and `Long` objects, with quite a few issues when some of the notations mentioned above are used.

Is there a parser in the standard class library of, say, Java 6 and onwards that is able to transparently parse such strings and return the proper sub-class of `Number`? 
