For example I have the variable 3.545555555, which I would want to truncate to just 3.54.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Check available
RoundingMode
andDecimalFormat
.Here is the method I use:
This can also be done:
This worked for me:
I personally like this version because it actually performs the rounding numerically, rather than by converting it to a String (or similar) and then formatting it.