当前位置:网站首页>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--;
}
}
}
}
边栏推荐
- Scala language learning-08-abstract classes
- Google可能在春节后回归中国市场。
- Ble of Jerry [chapter]
- HTTP cache, forced cache, negotiated cache
- http缓存,强制缓存,协商缓存
- Methods for JS object to obtain attributes (. And [] methods)
- After the hot update of uniapp, "mismatched versions may cause application exceptions" causes and Solutions
- WebRTC系列-H.264预估码率计算
- 1015 reversible primes (20 points) prime d-ary
- How to delete all the words before or after a symbol in word
猜你喜欢
![[cf gym101196-i] waif until dark network maximum flow](/img/66/6b339fc23146b5fbdcd2a1fa0a2349.png)
[cf gym101196-i] waif until dark network maximum flow

Google may return to the Chinese market after the Spring Festival.

解决方案:智慧工地智能巡檢方案視頻監控系統
![If Jerry needs to send a large package, he needs to modify the MTU on the mobile terminal [article]](/img/57/12a97ab3d2dabfaf06bbe1788450cf.png)
If Jerry needs to send a large package, he needs to modify the MTU on the mobile terminal [article]

leecode-C語言實現-15. 三數之和------思路待改進版

Qualitative risk analysis of Oracle project management system

octomap averageNodeColor函数说明

Leecode-c language implementation -15 Sum of three ----- ideas to be improved

数字经济时代,如何保障安全?

Pre knowledge reserve of TS type gymnastics to become an excellent TS gymnastics master
随机推荐
Games101 Lesson 7 shading 1 Notes
[MySQL learning notes 30] lock (non tutorial)
Scala语言学习-08-抽象类
Iterator Foundation
C # connect to SQLite database to read content
Luogu p4127 [ahoi2009] similar distribution problem solution
Typescript interface properties
1015 reversible primes (20 points) prime d-ary
Three treasures of leeks and Chinese men's football team
Ble of Jerry [chapter]
MES, APS and ERP are essential to realize fine production
Sharing of source code anti disclosure scheme under burning scenario
Force buckle day31
Is the super browser a fingerprint browser? How to choose a good super browser?
Bit operation XOR
Methods for JS object to obtain attributes (. And [] methods)
软件开发的一点随记
Type of data in energy dashboard
HTTP cache, forced cache, negotiated cache
After the hot update of uniapp, "mismatched versions may cause application exceptions" causes and Solutions