Value of TextField.NUMERIC is limited to 10 digits in Series 40 (Known Issue)
Article Metadata
Tested with
Devices(s): All Series 40 devices
Compatibility
Platform(s): All Series 40 Editions
Article
Created: User:Technical writer 1
(April 2, 2008, updated April 16, 2008)
Last edited: hamishwillee
(05 Jul 2012)
Contents |
Overview
In Series 40, the value of TextField.NUMERIC must not exceed the value of 2147483646 (Integer.MAX_VALUE-1), otherwise an IllegalArgumentException is thrown.
Description
The integer value inserted in TextField defined with the TextField.NUMERIC constraint must not exceed the value of 2147483646 (i.e. Integer.MAX_VALUE-1) in Series 40, otherwise an IllegalArgumentException is thrown. In S60, this value may be exceeded without the exception.
How to reproduce
Use, for example, the following piece of code to reproduce this issue:
TextField textField = new TextField("Enter Number:", "", 10, TextField.NUMERIC);
long n = Integer.MAX_VALUE;
textField.setString(Long.toString(n));
System.out.println("OK for Integer.MAX_VALUE, i.e. " + n);
try {
textField.setString(Long.toString(++n));
}
catch (IllegalArgumentException e) {
System.out.println("FAILED for Integer.MAX_VALUE + 1, i.e. " + n);
}
Solution
Avoid using values starting from Integer.MAX_VALUE and higher with the TextField.NUMERIC constraint in Series 40.


I think the problem is not only limited to the number of digits but to the value itself, too:
If you call setString(...) on a TextField constrained to TextField.Numeric and the numeric value exceeds Integer.MAX_VALUE then an IllegalArgumentException is thrown.
How to reproduce
TextField textField = new TextField("Enter Number:", "", 10, TextField.NUMERIC); long n = Integer.MAX_VALUE; textField.setString(Long.toString(n)); System.out.println("OK for Integer.MAX_VALUE, i.e. " + n); try { textField.setString(Long.toString(++n)); } catch (IllegalArgumentException e) { System.out.println("FAILED for Integer.MAX_VALUE + 1, i.e. " + n); }Thank you for your feedback. The article has been updated.
Forum Nokia KB 14:58, 16 April 2008 (EEST)