Python 官方文档:入门教程 => 点击学习
mybatis日期格式自动转换 public class Student { public Integer id; public String studentNa
public class Student {
public Integer id;
public String studentName;
@JSONFORMat(pattern="yyyy-MM-dd") //从数据库读出日期格式时,进行转换的规则
@DateTimeFormat(pattern = "yyyy-MM-dd")//接受从前端传入的日期格式,映射到java类日期属性的规则
public Date birth;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getStudentName() {
return studentName;
}
public void setStudentName(String studentName) {
this.studentName = studentName;
}
public Date getBirth() {
return birth;
}
public void setBirth(Date birth) {
this.birth = birth;
}
}
- select操作
@Select("select date_format(createTime,'%Y-%m-%d') from tb where id = ?")
- update操作
更新为当前时间
@Update("update tb set createTime = date_format(now(),'%Y-%m-%d %H:%i:%s') where id = ?")
更新为指定时间
@Update("update tb set createTime = #{param, jdbcType=DATE} where id = ?")
@Update("update tb set createTime = #{param, jdbcType=TIMESTAMP } where id = ?")
关于Mysql Date 函数的用法 参考这里
以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程网。
--结束END--
本文标题: Mybatis日期格式自动转换需要用到的两个注解说明
本文链接: https://www.lsjlt.com/news/131987.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0