There are two ways to limit the format of the two decimal places after the decimal point on Android (I personally use it in the project, but it does not mean that there are only two, there are many more). Well, I won’t say much nonsense, the above content.
1. The first method: Use the DecimalFormat API
DecimalFormat format = new DecimalFormat("#.##"); String numberStr = (numberDecimal); ("TAG","numberStr => " + numberStr);
2. The second method: use the () function
String price = ().toString().trim(); if((".")[1].length() > 2){ //TODO... }
OK, these are the two methods I used to limit the display of the two decimal places. There must be other ones. Welcome to complain, haha~~
The above method of limiting the display of two decimal places in Android is all the content I share with you. I hope you can give you a reference and I hope you can support me more.