当前位置:网站首页>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--;
}
}
}
}
边栏推荐
- Opencv learning notes 9 -- background modeling + optical flow estimation
- Scala language learning-08-abstract classes
- [factorial inverse], [linear inverse], [combinatorial counting] Niu Mei's mathematical problems
- 软件测试界的三无简历,企业拿什么来招聘你,石沉大海的简历
- If Jerry's Bluetooth device wants to send data to the mobile phone, the mobile phone needs to open the notify channel first [article]
- Wonderful use of TS type gymnastics string
- Get/post/put/patch/delete meaning
- C # create database connection object SQLite database
- 链表面试题(图文详解)
- C intercept string
猜你喜欢

成为优秀的TS体操高手 之 TS 类型体操前置知识储备

解决方案:智慧工地智能巡检方案视频监控系统

Force buckle day31
![[MySQL learning notes 30] lock (non tutorial)](/img/9b/1e27575d83ff40bebde118b925f609.png)
[MySQL learning notes 30] lock (non tutorial)

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower

Three no resumes in the software testing industry. What does the enterprise use to recruit you? Shichendahai's resume
![[cf gym101196-i] waif until dark network maximum flow](/img/66/6b339fc23146b5fbdcd2a1fa0a2349.png)
[cf gym101196-i] waif until dark network maximum flow
TS 类型体操 之 extends,Equal,Alike 使用场景和实现对比

TS 类型体操 之 循环中的键值判断,as 关键字使用

Mex related learning
随机推荐
1015 reversible primes (20 points) prime d-ary
WebRTC系列-H.264预估码率计算
Sharing of source code anti disclosure scheme under burning scenario
Ble of Jerry [chapter]
[KMP] template
xpath中的position()函数使用
How to delete all the words before or after a symbol in word
Codeforces Global Round 19(A~D)
(lightoj - 1410) consistent verbs (thinking)
DataX self check error /datax/plugin/reader/_ drdsreader/plugin. Json] does not exist
2022年Instagram运营小技巧简单讲解
成为优秀的TS体操高手 之 TS 类型体操前置知识储备
Simulation of Michelson interferometer based on MATLAB
JMeter performance test steps practical tutorial
Typescript interface and the use of generics
Redis builds clusters
Ali's redis interview question is too difficult, isn't it? I was pressed on the ground and rubbed
[nonlinear control theory]9_ A series of lectures on nonlinear control theory
Pre knowledge reserve of TS type gymnastics to become an excellent TS gymnastics master
datax自检报错 /datax/plugin/reader/._drdsreader/plugin.json]不存在