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); 

0 comments:

Post a Comment