@GetMapping("/currentDateTime")
public Date currentDateTime() {
return new Date();
}
The Date json time format returned by default is
If you want to return a custom format like "yyyy-MM-dd HH:mm:ss", you need to configure the following
spring:
# 设置返回json的全局时间格式
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8