当前位置:网站首页>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--;
}
}
}
}
边栏推荐
- 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
- Full Score composition generator: living on code
- How to estimate the number of threads
- Methods for JS object to obtain attributes (. And [] methods)
- The way to learn go (I) the basic introduction of go to the first HelloWorld
- C # connect to SQLite database to read content
- Interview Reply of Zhuhai Jinshan
- 软件开发的一点随记
- Ble of Jerry [chapter]
- Select all the lines with a symbol in word and change them to titles
猜你喜欢

Fundamentals of C language 9: Functions

opencv学习笔记九--背景建模+光流估计
![Jerry's ad series MIDI function description [chapter]](/img/28/e0f9b41db597ff3288af431c677001.png)
Jerry's ad series MIDI function description [chapter]

Pre knowledge reserve of TS type gymnastics to become an excellent TS gymnastics master

Machine learning - decision tree
![Ble of Jerry [chapter]](/img/00/27486ad68bf491997d10e387c32dd4.png)
Ble of Jerry [chapter]
![[factorial inverse], [linear inverse], [combinatorial counting] Niu Mei's mathematical problems](/img/6d/282d904810807810adb06b071fb39b.jpg)
[factorial inverse], [linear inverse], [combinatorial counting] Niu Mei's mathematical problems

Google可能在春节后回归中国市场。

Basics of reptile - Scratch reptile

Do you really think binary search is easy
随机推荐
leecode-C语言实现-15. 三数之和------思路待改进版
Simulation of Michelson interferometer based on MATLAB
C # connect to SQLite database to read content
[count] [combined number] value series
Transformer principle and code elaboration
leecode-C語言實現-15. 三數之和------思路待改進版
Linked list interview questions (Graphic explanation)
Solution: système de surveillance vidéo intelligent de patrouille sur le chantier
Iterator Foundation
超级浏览器是指纹浏览器吗?怎样选择一款好的超级浏览器?
Pre knowledge reserve of TS type gymnastics to become an excellent TS gymnastics master
解决方案:智慧工地智能巡檢方案視頻監控系統
Simulation of holographic interferogram and phase reconstruction of Fourier transform based on MATLAB
WebRTC系列-H.264预估码率计算
opencv学习笔记八--答题卡识别
二叉树创建 & 遍历
Helm install Minio
C # display the list control, select the file to obtain the file path and filter the file extension, and RichTextBox displays the data
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
数据治理:误区梳理篇