springboot处理日期类型,前后端,完整流程
先看我的项目,
实体类中,定义的是date类型的两个数据
解决:在实体类中日期类型的数据上添加注解,就可以将String-date
这个是谷咕咕在看博客的时候看到的,还不错,挺有用的
@JsonFormat(shape = JsonFormat.Shape.STRING,pattern="yyyy-MM-dd",timezone = "GMT+8")
前端
<div class="input-daterange input-group">
<input class="form-control js-datepicker" data-date-format="yyyy-mm-dd" type="text" name="starttime" placeholder="从">
<span class="input-group-addon"><i class="mdi mdi-chevron-right"></i></span>
<input class="form-control js-datepicker" data-date-format="yyyy-mm-dd" type="text" name="endtime" placeholder="至">
</div>
数据库,定义的也是datetime类型