Commit 1adcd4f4 authored by duanruiming's avatar duanruiming

[add] Double类型保留两位小数

parent 7ee9a099
...@@ -12,7 +12,7 @@ import java.text.DecimalFormat; ...@@ -12,7 +12,7 @@ import java.text.DecimalFormat;
* @date 2024/12/01 16:17 * @date 2024/12/01 16:17
*/ */
public class Double2TwoDecimalPlacesSerializer extends JsonSerializer<Double> { public class Double2TwoDecimalPlacesSerializer extends JsonSerializer<Double> {
private static final DecimalFormat df = new DecimalFormat("#.00"); private static final DecimalFormat df = new DecimalFormat("#0.00");
@Override @Override
public void serialize(Double value, JsonGenerator gen, SerializerProvider serializers) throws IOException { public void serialize(Double value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
......
...@@ -12,7 +12,7 @@ import java.text.DecimalFormat; ...@@ -12,7 +12,7 @@ import java.text.DecimalFormat;
* @date 2024/12/01 16:17 * @date 2024/12/01 16:17
*/ */
public class DoubleToTwoDecimalPlacesSerializer extends JsonSerializer<Double> { public class DoubleToTwoDecimalPlacesSerializer extends JsonSerializer<Double> {
private static final DecimalFormat df = new DecimalFormat("#.00"); private static final DecimalFormat df = new DecimalFormat("#0.00");
@Override @Override
public void serialize(Double value, JsonGenerator gen, SerializerProvider serializers) throws IOException { public void serialize(Double value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment