I am retrieving a value from DB.
Datatype in DB:---- number(6,2).

So i retrieved as decimal from db as getdouble(attrubute)

So if 10 is present in DB i am getting 10.0.

Is there any way to get 10 and at the same time if 10.2 is there i require as 10.2 only.

So after point if 0 is there i dont require as decimal .I require it as just as 10

Thanks in advance

The DecimalFormat class will allow you to specify a format string to control such things. Look it up in the API.

The String.format() and PrintStream.printf() functions also allow such formatting.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.