How can I strip decimal points in jsp/java.

I want to trim decimal points from a imported excel spreadsheet using jsp/java.

When I import  numbers such as 30 from a spreadsheet the number displays 30.0
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

String numb = s0.substring(0,s0.indexOf("."));

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
javadevmanAuthor Commented:
Solved my issue
javadevmanAuthor Commented:
What about trailing decimal numbers. The code above strips all numbers after a decimal point
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

You can use DecimalFormat class to specify how many decimal digits you need. You can then convert the string to float, then check if after casting to int you'll have the same number and if it is diffrernt then format it with the required numbe fo decimal digits
I think experimenting with DecimalFormat with different constructors made up of zeroes or hash signs in the quoted template will allow you to format your double value in such a way that it prints no dots when the value is equal to integer or will print dots and decimal digits when the value is not exactly equal to integer. Unfortunately for the few days I will not have access to my computer, so I cannot give you the exact way. Using if's to compare if the number is equal to its integer part, though, you can achieve the same result with a little bit more code.
javadevmanAuthor Commented:
I will experiment with it over the weekend  man. Sorry about your cpu.  Do you know anything about jstl? Any good sites for a newbie?

This is rather old, but pretty logical explanation of the JSTL starting with the explanation of the basics:

I guess you needed to use DecimalFormat in this variant:
   DecimalFormat df500 = new DecimalFormat("####.##");

This is how I tested it:

        DecimalFormat df500 = new DecimalFormat("####.##");
        double d30 = 30.0;
        double d3002 = 30.02;

        System.out.println("d30: " + df500.format(d30));

        System.out.println("d3002: " + df500.format(d3002));

Open in new window

This is the output:
d30: 30
d3002: 30.02

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.