-1

Possible Duplicate:
How to convert number to words in java

I am trying to set the long value in the textfield the modification of my code is as below error what it is showing is required long found int

 private void jTextField2MouseClicked(java.awt.event.MouseEvent evt) {
        if(evt.getSource()==jTextField2){
            long jml = Long.parseLong(jTextField3.getText());

            jTextField1.setText(numberToWord(jml));

        }
    }
1
  • i actually updated some coding part and reposted it Jan 5, 2013 at 8:13

2 Answers 2

0

The NumberFormatException is Thrown to indicate that the application has attempted to convert a string to one of the numeric types, but that the string does not have the appropriate format. So, the exception could be because the maximum value of a java int is 2,147,483,647 (which is a 10-digit integer).

0

The error is occuring in the below line, And looks like you are using Integer.parseInt() method in the below line,

at myproj.Certificates.jTextField2MouseClicked(Certificates.java:268)

When the value that is being passed to the method Integer.parseInt() is greater than Integer.MAX_VALUE (2,147,483,647), you will receive the java.lang.NumberFormatException.

And since 10000000000 is greater than 2,147,483,647 you are getting the NumberFormatException.

5
  • 1
    So use long, Long.parseLong.
    – Joop Eggen
    Jan 5, 2013 at 7:44
  • long jml = Long.parseLong.(jTextField3.getText()); i tried above but its showing identifier expected error Jan 5, 2013 at 8:06
  • long jml = Long.parseLong.(jTextField3.getText()); i tried above but its showing identifier expected error Jan 5, 2013 at 8:14
  • Are you using DOT (.) before ......(jTextField3.getText()); ..... If yes remove the same
    – Jayamohan
    Jan 5, 2013 at 8:25
  • ya done but now its showing required long found int error Jan 5, 2013 at 8:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.