How to store an integer value from excel without the decimal points

Hi

I have an ID field in excel, which I read from a java application. I store the ID field in a  String variable, but the problem is that it stores the value with a .0 at the end. So for eg 456 is stored as 456.0. How can i store the value like 456 only. Any help will be greatly appreciated
royalcyberAsked:
Who is Participating?
 
sciuriwareConnect With a Mentor Commented:
More secure:

  String a = "456.0";
.............

  int index;

      if((index = a.indexOf('.')) >= 0)
      {
         a = a.substring(0, index);
      }

// a is now shortened to a string without .xxx  to any purpose.

;JOOP!
0
 
sciuriwareCommented:
String a = "456.0";
int i = Integer.parseInt(a.substring(0, a.indexOf('.')));

;JOOP!
0
 
sciuriwareCommented:
But only if you are certain that the   .    is present.

;JOOP!
0
 
CEHJCommented:
You could do

String a = "" + (int)Double.parseDouble(originalString);
0
 
sciuriwareCommented:
:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.