String TotalAmount= "";
Lets say I have TotalAmount = 10
, or 10.1
or 10.11
or 10.11111
BigDecimal Amount = new BigDecimal(amount);
I want Amount
in this pattern #.##
10 -> 10.00
10.1 -> 10.10
10.11 -> 10.11
10.11111 -> 10.11
Solved it myself
BigDecimal TotalAmount= new BigDecimal(myAmount);
BigDecimal Amount = TotalAmount.divide(new BigDecimal(1),2, RoundingMode.HALF_UP);