当前位置:网站首页>Entity class design for calculating age based on birthday
Entity class design for calculating age based on birthday
2022-07-06 07:46:00 【Yixin running code】
package com.szxs.bean.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Document(indexName = "staff", type = "staff", replicas = 1, shards = 4)
public class StaffVo {
@Id
private Integer id;
@Field(type = FieldType.Keyword)
private String userName;
@Field(type = FieldType.Keyword)
private String password;
@Field(type = FieldType.Text, analyzer = "standard")
private String realName;
@Field(type = FieldType.Integer)
private Integer gender;
@Field(type = FieldType.Date)
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date birthday;
@Field(type = FieldType.Keyword)
private String phone;
@Field(type = FieldType.Text, analyzer = "ik_smart")
private String address;
@Field(type = FieldType.Integer)
private Integer roleId;
@Field(type = FieldType.Keyword)
private String genderName;
@Field(type = FieldType.Text, analyzer = "ik_smart")
private String roleName;
@Field(type = FieldType.Integer)
private Integer age;
@Override
public String toString() {
return "StaffVo{" +
"id=" + id +
", userName='" + userName + '\'' +
", password='" + password + '\'' +
", realName='" + realName + '\'' +
", gender=" + gender +
", birthday=" + birthday +
", phone='" + phone + '\'' +
", address='" + address + '\'' +
", roleId=" + roleId +
", genderName='" + genderName + '\'' +
", roleName='" + roleName + '\'' +
", age=" + age +
'}';
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getRealName() {
return realName;
}
public void setRealName(String realName) {
this.realName = realName;
}
public Integer getGender() {
return gender;
}
public void setGender(Integer gender) {
this.gender = gender;
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
setAge();
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public Integer getRoleId() {
return roleId;
}
public void setRoleId(Integer roleId) {
this.roleId = roleId;
}
public String getGenderName() {
return genderName;
}
public void setGenderName(String genderName) {
this.genderName = genderName;
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public Integer getAge() {
return age;
}
private void setAge() {
// Get the current time
Date now = new Date();
// Calculate base age
age = now.getYear() - birthday.getYear();
// Judge , month
if (now.getMonth() < birthday.getMonth()){
age--;
}else if (now.getMonth() == birthday.getMonth()){
// Judge , Japan
if (now.getDate() < birthday.getDate()){
age--;
}
}
}
}
边栏推荐
- C # connect to SQLite database to read content
- 解决方案:智慧工地智能巡检方案视频监控系统
- WebRTC系列-H.264预估码率计算
- xpath中的position()函数使用
- Jerry's ad series MIDI function description [chapter]
- 2022年Instagram运营小技巧简单讲解
- Launch APS system to break the problem of decoupling material procurement plan from production practice
- P3047 [usaco12feb]nearby cows g (tree DP)
- [1. Delphi foundation] 1 Introduction to Delphi Programming
- [cf gym101196-i] waif until dark network maximum flow
猜你喜欢
Key value judgment in the cycle of TS type gymnastics, as keyword use
Google may return to the Chinese market after the Spring Festival.
When the Jericho development board is powered on, you can open the NRF app with your mobile phone [article]
[MySQL learning notes 32] mvcc
Ali's redis interview question is too difficult, isn't it? I was pressed on the ground and rubbed
Solution: système de surveillance vidéo intelligent de patrouille sur le chantier
DataX self check error /datax/plugin/reader/_ drdsreader/plugin. Json] does not exist
Simulation of holographic interferogram and phase reconstruction of Fourier transform based on MATLAB
[cf gym101196-i] waif until dark network maximum flow
Simulation of Teman green interferometer based on MATLAB
随机推荐
Solution: système de surveillance vidéo intelligent de patrouille sur le chantier
上线APS系统,破除物料采购计划与生产实际脱钩的难题
Full Score composition generator: living on code
C # connect to SQLite database to read content
解决方案:智慧工地智能巡检方案视频监控系统
C # create database connection object SQLite database
[computer skills]
Compliance and efficiency, accelerate the digital transformation of pharmaceutical enterprises, and create a new document resource center for pharmaceutical enterprises
Hackathon ifm
Rust language - receive command line parameter instances
Google may return to the Chinese market after the Spring Festival.
Opencv learning notes 9 -- background modeling + optical flow estimation
Wonderful use of TS type gymnastics string
Basics of reptile - Scratch reptile
If Jerry needs to send a large package, he needs to modify the MTU on the mobile terminal [article]
C intercept string
HTTP cache, forced cache, negotiated cache
Get the path of edge browser
Bit operation XOR
Mise en œuvre du langage leecode - C - 15. Somme des trois chiffres - - - - - idées à améliorer