机构树

This commit is contained in:
Wang.Huan
2025-03-05 17:14:28 +08:00
parent 540688bee7
commit 6c9d4fc0ea
8 changed files with 154 additions and 94 deletions

View File

@@ -2,7 +2,9 @@ package com.core.common.utils;
import java.time.LocalDateTime;
import java.time.Period;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.Date;
/**
* 根据出生日期算年龄
@@ -15,7 +17,9 @@ public final class AgeCalculatorUtil {
/**
* 当前年龄取得(床位列表表示年龄用)
*/
public static String getAge(LocalDateTime dateTime) {
public static String getAge(Date date) {
// 将 Date 转换为 LocalDateTime
LocalDateTime dateTime = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
LocalDateTime now = LocalDateTime.now();
int years = now.getYear() - dateTime.getYear();
if (years > 2) {
@@ -78,5 +82,4 @@ public final class AgeCalculatorUtil {
private static boolean isLeapYear(int year) {
return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}
}
}