@Data public class xxxQuery{ //字符串转Date @DateTimeFormat(pattern = "<dateformate>") private Date date; }
@Data public class xxxVO{ //Date转字符串 @JsonFormat(pattern = "<dateformate>") private Date date; }
例如:
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@RestController public class xxxController{ @GetMapping("/") public xxxVO xxx(xxxQuery query){ xxxVO vo = new xxxVO(); vo.setDate(new Date()); return vo; } }
标签:xxxVO,springboot,pattern,class,vo,Date,互转,public From: https://www.cnblogs.com/junlu/p/16863817.html