aspose file tools
The moose likes Servlets and the fly likes Number Format Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Number Format Exception" Watch "Number Format Exception" New topic
Author

Number Format Exception

mou haj
Ranch Hand

Joined: Sep 12, 2001
Posts: 81
java.lang.NumberFormatException: 1000000000099
ihave a number 1000000000099 and im wanting to do parse in /parse long but im getting number format exception why??? please help
sriramakrishna besta
Greenhorn

Joined: Sep 27, 2001
Posts: 3
/* try this code...
1. if u have 1000000000099 as a String object, change it to Lang object and then to long
2. if u have 1000000000099 as a Long object chage it to long
--- see java.Lang package for details ---
*/
class help1
{
public static void main(String[] args)
{
String S="1000000000099";
/* trim() to remove extra spaces from the strng value */
Long L=new Long(S.trim());
long l=L.longValue();
System.out.println("S is "+S);
System.out.println("L is "+L);
System.out.println("l is "+l);
}
}
regards
ramakrishna
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by sriramakrishna besta:
1. if u have 1000000000099 as a String object, change it to Lang object and then to long
2. if u have 1000000000099 as a Long object chage it to long
In actual fact, the constructor for Long(String) uses Long.parseLong(String) to convert the string into a long first! Creating a Long object just to parse a string is a waste of perfectly good CPU cycles; Long.parseLong() should do the job.
Without more information it's difficult to say what's wrong.
- Peter

[This message has been edited by Peter den Haan (edited October 03, 2001).]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Number Format Exception
 
Similar Threads
Doubt in NumberFormat.
Regarding Date functions in java
help with number formats
urgent!!!!not getting logic
Problem in SimpleDateFormat