×
Namespaces

Variants
Actions
Revision as of 08:55, 28 June 2012 by hamishwillee (Talk | contribs)

Archived:TextField.setString() may throw an IllegalArgumentException in Series 40 2nd Edition devices if TextField.DECIMAL is used (Known Issue)

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: 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
CompatibilityArticle
Created: User:Technical writer 1 (07 Feb 2008)
Last edited: hamishwillee (28 Jun 2012)
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:

 TextField txt;
..
txt = new TextField("Value:", "", 20, TextField.DECIMAL);
txt.setString(Double.toString(Math.PI));

Or this:

 TextField txt;
..
txt = new TextField("Value:", "", 20, TextField.DECIMAL);
textField.setString("3.141592653");

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.

64 page views in the last 30 days.
×