How to split integer and decimal part in java

This is simple tutorials but frequently useful when you developing application in android and software in java.

                                 double d= 234.12413;
String text = Double.toString(Math.abs(d));
int integerPlaces = text.indexOf('.');
int decimalPlaces = text.length() - integerPlaces - 1;
System.out.println("----integerPlaces +integerPlaces+"===decimalPlaces=="+decimalPlaces); 

No comments:

Post a Comment

Circle

Most recent Elastic Search tutorials for beginner, intermediate and advance level developer, Yubraj Pokharel, in CodingWorkspace