United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6431200 : [Fmt-Nu] Provide a strict mode for NumberFormat

Details
Type:
Enhancement
Submit Date:
2006-05-26
Status:
Closed
Updated Date:
2010-11-19
Project Name:
JDK
Resolved Date:
2010-11-19
Component:
core-libs
OS:
windows_xp
Sub-Component:
java.text
CPU:
x86
Priority:
P3
Resolution:
Won't Fix
Affected Versions:
5.0,6
Fixed Versions:

Related Reports
Duplicate:
Relates:

Sub Tasks

Description
NumberFormat is currently a bit leniant. It will parse '123xx' but not 'xx123'. Folks using JFormattedTextField that want number parsing use NumberFormat. It's not expected that either string would be valid, instead both should throw an exception. Obviously we can't change this now, so perhaps we could add an option to turn on strict parsing.

                                    

Comments
WORK AROUND

Use a ParsePosition to get the index after parsing. If ParsePostion.getIndex() != string.length(), then parse() didn't consume the entire string.
                                     
2006-06-05
EVALUATION

Developers can easily write code which checks if the given text includes an unexpected character before/after digits using ParsePosition and ParseException.
I have no plan to add a method for the strict mode.
*** (#1 of 1): [ UNSAVED ] ###@###.###
                                     
2010-11-19



Hardware and Software, Engineered to Work Together