Get Two digit after decimal point in Android or Java
Try this:- private static String getDecimalFormat ( double value ) { String getValue = String . valueOf ( value ). split ( "[.]" )[ 1 ]; if ( getValue . length () == 1 ) { return String . valueOf ( value ). split ( "[.]" )[ 0 ] + "." + getValue . substring ( 0 , 1 ) + String . format ( "%0" + 1 + "d" , 0 ); } else { return String . valueOf ( value ). split ( "[.]" )[ 0 ] + "." + getValue . substring ( 0 , 2 ); } } Outputs:- System.out.println("value getDecimalFormat:- " + getDecimalFormat(1.0)); value getDecimalFormat:- 1.00 System.out.println("value getDecimalFormat:- " + getDecimalFormat(0.1234567891)); value getDecimalFormat:- 0.12 System.out.println("value getDecimalFormat:- " + getDecimalFormat(-44.0)); value getDecimalFormat:- -44.00 System.out.pr...


useful!
ReplyDeleteUseful
ReplyDeleteKing Casino Login | All your games online and - Community Khabar
ReplyDeleteLogin King Casino, Play, and Win! Login King Casino, Play. Login King Casino, https://jancasino.com/review/merit-casino/ Play. Login King Casino, Play. Login communitykhabar King Casino, 1xbet korean Play. septcasino Login King Casino, Play. Login King Casino,