https://www.cnblogs.com/lrzr/archive/2017/08/07/7299211.html
https://blog.csdn.net/weixin_38336276/article/details/83892408
https://www.cnblogs.com/1130136248wlxk/articles/5238538.html
------------------------------------------------------------------------------------------------------------------------
数据库中存的是timestamp,
对应实体类是timestamp:
package com.zte.claa.inficombo.app.model.version;
import java.sql.Timestamp;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zte.claa.inficombo.api.Constants;
public class DevVersionBase {
private static final String DTFormat = "yyyy-MM-dd HH:mm:ss";
public static final String TIME_ZONE = "GMT+8";
public static final int TPFLAG_DEVVER = 1;
public static final int TPFLAG_GPSEPH = 2;
private String devtype; // 设备类型ID VARCHAR(100) N 主键
private String version; // 版本编号 VARCHAR(100) N 主键,星历文件:GPS_EP_Date
private String devtpname; // 设备类型名称 VARCHAR(100) N
private String devtpdescp; // 设备类型描述 VARCHAR(200) Y
private int typeflag; // 版本类别 Int 1 N 1--终端版本;2--GPS星历;3--预留,待扩充
@JsonFormat(pattern=DTFormat, timezone =TIME_ZONE)
private Timestamp reltime; // 发布时间 Timestamp Y
private int versize = 1; // 版本大小 Int 1 N 单位:Byte
private int blocknum = 1; // 版本块数目 Int 1 N
private String crc32; // CRC32校验和 VARCHAR(10) Y 整个版本的校验和,十六进制数字字符串
private String remark; // 备注 Varchar(200) Y
private String filename; // 版本文件名.
public DevVersionBase(){
}
public String getDevtype() {
return devtype;
}
public void setDevtype(String devtype) {
this.devtype = devtype;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getDevtpname() {
return devtpname;
}
public void setDevtpname(String devtpname) {
this.devtpname = devtpname;
}
public String getDevtpdescp() {
return devtpdescp;
}
public void setDevtpdescp(String devtpdescp) {
this.devtpdescp = devtpdescp;
}
public int getTypeflag() {
return typeflag;
}
public void setTypeflag(int typeflag) {
this.typeflag = typeflag;
}
public Timestamp getReltime() {
return reltime;
}
public void setReltime(Timestamp reltime) {
this.reltime = reltime;
}
public int getVersize() {
return versize;
}
public void setVersize(int versize) {
this.versize = versize;
}
public int getBlocknum() {
return blocknum;
}
public void setBlocknum(int blocknum) {
this.blocknum = blocknum;
}
public String getCrc32() {
return crc32;
}
public void setCrc32(String crc32) {
this.crc32 = crc32;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getFilename() {
return filename;
}
public void setFilename(String filename) {
this.filename = filename;
}
public String toString(){
StringBuilder sb = new StringBuilder();
sb.append("devtype=").append(this.devtype).append(", ");
sb.append("version=").append(this.version).append(", ");
sb.append("devtpname=").append(this.devtpname).append(", ");
sb.append("devtpdescp=").append(this.devtpdescp).append(", ");
sb.append("typeflag=").append(this.typeflag).append(", ");
sb.append("reltime=").append(this.reltime).append(", ");
sb.append("versize=").append(this.versize).append(", ");
sb.append("blocknum=").append(this.blocknum).append(", ");
sb.append("crc32=").append(this.crc32).append(", ");
sb.append("filename=").append(this.filename).append(", ");
sb.append("remark=").append(this.remark);
return sb.toString();
}
}
------------------------------------------------------------------------------------------------------------------------
数据库中存的是datetime,
对应实体类是timestamp:
package com.zte.claa.inficombo.apigwv1.app.framework.model.personloc;
import java.sql.Timestamp;
public class PersonInOutFenceData {
private String personid;
private String personname;
private int sex;
private String jobid;
private String job;
private int flag;
private Timestamp intime;
private Timestamp outtime;
private String fenceid;
private String fencename;
public PersonInOutFenceData(){
}
public String getPersonid() {
return personid;
}
public void setPersonid(String personid) {
this.personid = personid;
}
public String getPersonname() {
return personname;
}
public void setPersonname(String personname) {
this.personname = personname;
}
public int getSex() {
return sex;
}
public void setSex(int sex) {
this.sex = sex;
}
public String getJobid() {
return jobid;
}
public void setJobid(String jobid) {
this.jobid = jobid;
}
public String getJob() {
return job;
}
public void setJob(String job) {
this.job = job;
}
public int getFlag() {
return flag;
}
public void setFlag(int flag) {
this.flag = flag;
}
public Timestamp getIntime() {
return intime;
}
public void setIntime(Timestamp intime) {
this.intime = intime;
}
public Timestamp getOuttime() {
return outtime;
}
public void setOuttime(Timestamp outtime) {
this.outtime = outtime;
}
public String getFenceid() {
return fenceid;
}
public void setFenceid(String fenceid) {
this.fenceid = fenceid;
}
public String getFencename() {
return fencename;
}
public void setFencename(String fencename) {
this.fencename = fencename;
}
}
------------------------------------------------------------------------------------------------------------------------
数据库中存date,实体类中存date;
数据库中存datetime,实体类中存date,但是要加上格式化
/** **/
package com.zte.claa.inficombo.apigwv1.app.framework.dao.mysql.impl;
import java.io.Serializable;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zte.claa.inficombo.apigwv1.app.Constants;
public class DogAdopt implements Serializable {
String DATE_FORMAT = "yyyy-MM-dd";
String DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
String TIME_ZONE = "GMT+8";
public static final byte STATUS_ADOPTING = 0; //领养中
public static final byte STATUS_ADOPTED = 1; //已领养
/**
* 领养编号
*/
private String id;
/**
* 收容编号
*/
private String takeinid;
/**
* 领养人姓名
*/
private String keepername;
/**
* 领养人性别 0女 1男
*/
private byte keepersex;
/**
* 领养人证件类型 1身份证 2护照 3居住证 4其它
*/
private byte certtype;
/**
* 领养人证件号码
*/
private String certno;
/**
* 领养人出生日期
*/
@JsonFormat(pattern=DATE_FORMAT, timezone =TIME_ZONE)
private Date birthday;
/**
* 领养人户籍所在地
*/
private String residenceaddr;
/**
* 领养人手机号码
*/
private String mobilephone;
/**
* 经办人
*/
private String opname;
/**
* 申请时间
*/
@JsonFormat(pattern=DATETIME_FORMAT, timezone =TIME_ZONE)
private Date applytime;
/**
* 处理时间
*/
@JsonFormat(pattern=DATETIME_FORMAT, timezone =TIME_ZONE)
private Date optime;
/**
* 状态 0待领养 1已领养
*/
private byte status;
/**
* 项目ID
*/
private String projectid;
/**
* 备注
*/
private String remark;
/**
* t_dogm_dog_adopt
*/
private static final long serialVersionUID = 1L;
/**
* 领养编号
* @return id 领养编号
*/
public String getId() {
return id;
}
/**
* 领养编号
* @param id 领养编号
*/
public void setId(String id) {
this.id = id;
}
/**
* 收容编号
* @return takeinid 收容编号
*/
public String getTakeinid() {
return takeinid;
}
/**
* 收容编号
* @param takeinid 收容编号
*/
public void setTakeinid(String takeinid) {
this.takeinid = takeinid;
}
/**
* 领养人姓名
* @return keepername 领养人姓名
*/
public String getKeepername() {
return keepername;
}
/**
* 领养人姓名
* @param keepername 领养人姓名
*/
public void setKeepername(String keepername) {
this.keepername = keepername;
}
/**
* 领养人性别 0女 1男
* @return keepersex 领养人性别 0女 1男
*/
public byte getKeepersex() {
return keepersex;
}
/**
* 领养人性别 0女 1男
* @param keepersex 领养人性别 0女 1男
*/
public void setKeepersex(byte keepersex) {
this.keepersex = keepersex;
}
/**
* 领养人证件类型 1身份证 2护照 3居住证 4其它
* @return certtype 领养人证件类型 1身份证 2护照 3居住证 4其它
*/
public byte getCerttype() {
return certtype;
}
/**
* 领养人证件类型 1身份证 2护照 3居住证 4其它
* @param certtype 领养人证件类型 1身份证 2护照 3居住证 4其它
*/
public void setCerttype(byte certtype) {
this.certtype = certtype;
}
/**
* 领养人证件号码
* @return certno 领养人证件号码
*/
public String getCertno() {
return certno;
}
/**
* 领养人证件号码
* @param certno 领养人证件号码
*/
public void setCertno(String certno) {
this.certno = certno;
}
/**
* 领养人出生日期
* @return birthday 领养人出生日期
*/
public Date getBirthday() {
return birthday;
}
/**
* 领养人出生日期
* @param birthday 领养人出生日期
*/
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
/**
* 领养人户籍所在地
* @return residenceaddr 领养人户籍所在地
*/
public String getResidenceaddr() {
return residenceaddr;
}
/**
* 领养人户籍所在地
* @param residenceaddr 领养人户籍所在地
*/
public void setResidenceaddr(String residenceaddr) {
this.residenceaddr = residenceaddr;
}
/**
* 领养人手机号码
* @return mobilephone 领养人手机号码
*/
public String getMobilephone() {
return mobilephone;
}
/**
* 领养人手机号码
* @param mobilephone 领养人手机号码
*/
public void setMobilephone(String mobilephone) {
this.mobilephone = mobilephone;
}
/**
* 经办人
* @return opname 经办人
*/
public String getOpname() {
return opname;
}
/**
* 经办人
* @param opname 经办人
*/
public void setOpname(String opname) {
this.opname = opname;
}
/**
* 申请时间
* @return applytime 申请时间
*/
public Date getApplytime() {
return applytime;
}
/**
* 申请时间
* @param applytime 申请时间
*/
public void setApplytime(Date applytime) {
this.applytime = applytime;
}
/**
* 处理时间
* @return optime 处理时间
*/
public Date getOptime() {
return optime;
}
/**
* 处理时间
* @param optime 处理时间
*/
public void setOptime(Date optime) {
this.optime = optime;
}
/**
* 状态 0待领养 1已领养
* @return status 状态 0待领养 1已领养
*/
public byte getStatus() {
return status;
}
/**
* 状态 0待领养 1已领养
* @param status 状态 0待领养 1已领养
*/
public void setStatus(byte status) {
this.status = status;
}
/**
* 项目ID
* @return projectid 项目ID
*/
public String getProjectid() {
return projectid;
}
/**
* 项目ID
* @param projectid 项目ID
*/
public void setProjectid(String projectid) {
this.projectid = projectid;
}
/**
* 备注
* @return remark 备注
*/
public String getRemark() {
return remark;
}
/**
* 备注
* @param remark 备注
*/
public void setRemark(String remark) {
this.remark = remark;
}
}
------------------------------------------------------------------------------------------------------------------------
数据库中存datetime,实体类中存date,但是要加上格式化
package com.zte.claa.inficombo.app.model.smartconstruct;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zte.claa.inficombo.api.Constants;
public class PersonBadBehavior {
private String eventid;//事件编号
private String personid;//行为人
private String personname;//行为人
private String eventtype;//事件类型
private int level;//1-轻微;2-一般;3-严重
@JsonFormat(pattern=Constants.DATETIME_FORMAT, timezone = Constants.TIME_ZONE)
private Date eventtime;//发生时间
private String descp;//事件描述
private String dealret;//处理结果
private String projectid;//项目ID
private String remark;//备注
public String getEventid() {
return eventid;
}
public void setEventid(String eventid) {
this.eventid = eventid;
}
public String getPersonid() {
return personid;
}
public void setPersonid(String personid) {
this.personid = personid;
}
public String getEventtype() {
return eventtype;
}
public void setEventtype(String eventtype) {
this.eventtype = eventtype;
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public Date getEventtime() {
return eventtime;
}
public void setEventtime(Date eventtime) {
this.eventtime = eventtime;
}
public String getDescp() {
return descp;
}
public void setDescp(String descp) {
this.descp = descp;
}
public String getDealret() {
return dealret;
}
public void setDealret(String dealret) {
this.dealret = dealret;
}
public String getProjectid() {
return projectid;
}
public void setProjectid(String projectid) {
this.projectid = projectid;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getPersonname() {
return personname;
}
public void setPersonname(String personname) {
this.personname = personname;
}
}