java annotation Long to String, LocalDateTime to String to specify the time format

1. Convert LocalDateTime to String (choose one annotation)

@JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDateTime startTime;

2. Convert Long to String

@JsonSerialize(using = ToStringSerializer.class)
private Long id;

3. Convert BigDecimal to String

@JsonFormat(shape = JsonFormat.Shape.STRING)

private BigDecimal applyPrice;

Guess you like

Origin blog.csdn.net/qq_33767353/article/details/127978332