/*Method of constructing BigDecimal from numeric string
*Method of setting the number of decimal places of BigDecimal */ import java.math.BigDecimal; //Number string String StrBd= "1048576.1024" ; //Construct the value of string content BigDecimal type variable bd BigDecimal bd= new BigDecimal(StrBd); //Set the number of decimal places, the first variable is the number of decimal places, and the second variable is the rounding method (rounding) bd=bd.setScale( 2 , BigDecimal. ROUND_HALF_UP); //Convert to string output String OutString=bd.toString();
String amount =“¥990.00”; amount = amount.substring(0, 1); BigDecimal bd=new BigDecimal(amount); bd=bd.setScale(2, BigDecimal.ROUND_HALF_UP); memberExtend.setUsableAmount(bd);
-------------------------------------------------------------------------------------------------------
Reprint
Statement : This article is an original article by the blogger and may not be reproduced without the permission of the blogger.
--------------------------------------------------------------------------------------------------------
Come here, please give a thumbs up