@Temporal——指定查询Date格式
来源:互联网 发布:贷款抢单软件 编辑:程序博客网 时间:2024/06/05 13:30
@Temporal标签的作用很简单:
(1) 如果在某类中有Date类型的属性,数据库中存储可能是'yyyy-MM-dd hh:MM:ss'要在查询时获得年月日,在该属性上标注@Temporal(TemporalType.DATE) 会得到形如'yyyy-MM-dd' 格式的日期。
(2)如果在某类中有Date类型的属性,数据库中存储可能是'yyyy-MM-dd hh:MM:ss'要获得时分秒,在该属性上标注 @Temporal(TemporalType.TIME) 会得到形如'HH:MM:SS' 格式的日期。
(3)如果在某类中有Date类型的属性,数据库中存储可能是'yyyy-MM-dd hh:MM:ss'要获得'是'yyyy-MM-dd hh:MM:ss',在该属性上标注 @Temporal(TemporalType.TIMESTAMP) 会得到形如'HH:MM:SS' 格式的日期
注意:该注解只能用于java.util.Date或java.util.calendar类型的类属性上
@Entity@Table(name="mession")@DynamicInsert(true)public class Mession {@Id@GeneratedValue(strategy=GenerationType.IDENTITY)@Column(name="pk_id",length=11)private Integer pk_id;@Column(name="m_name")private String m_name;@Column(name="m_time")private String m_time;@Column(name="meaparam_id")private Integer meaparam_id;@Column(name="ts")@Temporal(TemporalType.TIMESTAMP)//获取数据库时间格式@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")//Hibernate中@ResponseBody返回的时间格式private Date ts;@Column(name="dr")private Integer dr;public Mession() {super();// TODO Auto-generated constructor stub}public Mession(Integer pk_id, String m_name, String m_time,Integer meaparam_id, Date ts, Integer dr) {super();this.pk_id = pk_id;this.m_name = m_name;this.m_time = m_time;this.meaparam_id = meaparam_id;this.ts = ts;this.dr = dr;}get/set()}
阅读全文
0 0
- @Temporal——指定查询Date格式
- php datetime 类型转指定date格式
- mysql 指定日期格式查询
- JSP格式——date类型
- hibernate jpa 注解 @Temporal(TemporalType.DATE)
- hibernate 注解使用日期@Temporal(TemporalType.DATE)
- JSONObject转换JSON--将Date转换为指定格式
- JSONObject转换JSON--将Date转换为指定格式
- JSONObject转换JSON--将Date转换为指定格式
- JSONObject转换JSON--将Date转换为指定格式
- JSONObject转换JSON--将Date转换为指定格式
- JSONObject转换JSON--将Date转换为指定格式
- JSONObject转换JSON--将Date转换为指定格式
- Temporal
- @Temporal
- @Temporal
- @Temporal
- 对Date的扩展,将 Date 转化为指定格式的String
- 百钱百鸡
- 安装并使用node.js
- js框架
- 左神面试算法整理--并归求小和
- vue.js几种不同组件(页面)间传值的方式
- @Temporal——指定查询Date格式
- ros机器人操作系统
- poj 1961 Period(kmp)
- POJ-3021 e-Coins(广搜)
- json工具类
- CPU核数和多线程的关系
- ActiveMQ在数据中的表说明(queue,durable topic)
- Git LF和CRLF问题解决记录
- 正则表达式和通配符的区别