From 53e7558400dcacecdce70e39ebfe1727740f9296 Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期六, 25 十一月 2023 17:20:06 +0800 Subject: [PATCH] 重写课包支付和排课逻辑 --- cloud-server-course/src/main/java/com/dsh/course/util/LocalDateTimeUtils.java | 25 ++++++++++++++----------- 1 files changed, 14 insertions(+), 11 deletions(-) diff --git a/cloud-server-course/src/main/java/com/dsh/course/util/LocalDateTimeUtils.java b/cloud-server-course/src/main/java/com/dsh/course/util/LocalDateTimeUtils.java index b706602..480fb71 100644 --- a/cloud-server-course/src/main/java/com/dsh/course/util/LocalDateTimeUtils.java +++ b/cloud-server-course/src/main/java/com/dsh/course/util/LocalDateTimeUtils.java @@ -16,8 +16,8 @@ * @version V1.0 */ public class LocalDateTimeUtils { - private final static int[] dayArr = new int[] { 20, 19, 21, 20, 21, 22, 23, 23, 23, 24, 23, 22 }; - private final static String[] constellationArr = new String[] { "摩羯座", "水瓶座", "双鱼座", "白羊座", "金牛座", "双子座", "巨蟹座", "狮子座", "处女座", "天秤座", "天蝎座", "射手座", "摩羯座" }; + private final static int[] dayArr = new int[]{20, 19, 21, 20, 21, 22, 23, 23, 23, 24, 23, 22}; + private final static String[] constellationArr = new String[]{"摩羯座", "水瓶座", "双鱼座", "白羊座", "金牛座", "双子座", "巨蟹座", "狮子座", "处女座", "天秤座", "天蝎座", "射手座", "摩羯座"}; /** @@ -34,16 +34,17 @@ /** * 通过生日计算年龄 + * * @param birthDay 生日 * @return * @throws ParseException */ public static int getAgeByBirth(LocalDate birthDay) throws ParseException { int age = 0; - //出生日期晚于当前时间,无法计算 - LocalDate now=LocalDate.now(); + //出生日期晚于当前时间,无法计算 + LocalDate now = LocalDate.now(); if (birthDay.isAfter(now)) { - throw new IllegalArgumentException( "生日大于当前时间!"); + throw new IllegalArgumentException("生日大于当前时间!"); } //当前年份 int yearNow = now.getYear(); @@ -52,14 +53,14 @@ //当前日期 int dayOfMonthNow = now.getDayOfMonth(); - int yearBirth =birthDay.getYear(); + int yearBirth = birthDay.getYear(); int monthBirth = birthDay.getMonthValue(); int dayOfMonthBirth = birthDay.getDayOfMonth(); //计算整岁数 age = yearNow - yearBirth; if (monthNow <= monthBirth) { if (monthNow == monthBirth) { - if (dayOfMonthNow < dayOfMonthBirth){ + if (dayOfMonthNow < dayOfMonthBirth) { //当前日期在生日之前,年龄减一 age--; } @@ -76,16 +77,17 @@ */ public static String getConstellation(LocalDate date) { - Integer month=date.getMonthValue(); - Integer day=date.getDayOfMonth(); + Integer month = date.getMonthValue(); + Integer day = date.getDayOfMonth(); return day < dayArr[month - 1] ? constellationArr[month - 1] : constellationArr[month]; } /** * 获取当天的星期几 + * * @return */ - public static int getWeekStr(){ + public static int getWeekStr() { LocalDate today = LocalDate.now(); DayOfWeek dayOfWeek = today.getDayOfWeek(); return dayOfWeek.getValue(); @@ -93,10 +95,11 @@ /** * 根据输入本周的周几,获取当天的时间 + * * @param dayOfWeekInput 周几 * @return */ - public static Date getDateOfWeekNum(int dayOfWeekInput){ + public static Date getDateOfWeekNum(int dayOfWeekInput) { // 获取当前日期 Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); -- Gitblit v1.7.1