How can I change DecimalFormat behavior based on input length?

后端 未结 2 1556
遇见更好的自我
遇见更好的自我 2021-02-15 10:55

I am using the following DecimalFormat pattern:

// Use ThreadLocal to ensure thread safety.
private static final ThreadLocal  nu         


        
2条回答
  •  盖世英雄少女心
    2021-02-15 11:43

    Have you tried to change the RoundingMode of your DecimalFormat instance?

    Calling setRoundingMode(RoundingMode.FLOOR) should do the trick

    See also setRoundingMode(java.math.RoundingMode)

提交回复
热议问题