Archived:TextField.setString() may throw an IllegalArgumentException in Series 40 2nd Edition devices if TextField.DECIMAL is used (Known Issue)
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.
Article Metadata
| ID | KIJ000813 | Creation date | February 7, 2008 |
| Platform | Series 40 2nd Edition Early firmware versions of Series 40 3rd Edition |
Devices | Nokia 3220, Nokia 5070 |
| Category | Java ME | Subcategory | MIDP 2.0 |
Contents |
Overview
TextField.setString(Double.toString(Math.PI)) throws IllegalArgumentException in Series 40 2nd Edition devices.
Description
TextField.setString(Double.toString(Math.PI)) throws IllegalArgumentException in Series 40 2nd Edition devices. This appears to be because maximum amount of decimal digits is exceeded: if there are more than 8 decimal digits after the decimal point, the defined exception will be thrown. Double.toString(Math.PI) returns a String of 17 characters (15 digits).
How to reproduce
Try this:
Or this:
Solution
Avoid reading more than 8 digits or use String.substring(int beginIndex, int endIndex) for shortening the String or use TextField of type ANY.


(no comments yet)