File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes How to handle DecimalFormat overflow? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to handle DecimalFormat overflow?" Watch "How to handle DecimalFormat overflow?" New topic
Author

How to handle DecimalFormat overflow?

Ben Ethridge
Ranch Hand

Joined: Jul 28, 2003
Posts: 108
Hi, all.

I was a bit surprised that this gave no overflow exception, and that java happily expands pattern to accept a too-large number, and that I have to, say, resort to comparing the length() of output to the length() of pattern, and create a custom exception if output "overflows".

Resorting to this seems a bit inelegant. After all, this is a concrete subclass of NumberFormat which is all about formatting numbers for display and reports and such, where field lengths matter quite a lot.

Is there anything in NumberFormat or its cousins that traps for overflowing numbers?



Ben Ethridge
SCJP 1.4
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
Is there anything in NumberFormat or its cousins that traps for overflowing numbers?


No...


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to handle DecimalFormat overflow?
 
Similar Threads
Explain me .
DecimalFormat is not setting the format for is_IS Language
NumberFormat without comma
thousands-separators
Padding Leading Zeros to String