day15总结(1. toString()、equals()方法 2. String、StringBuilder常用方法)

本文详细介绍了Java中字符串类String的基本特性和常用方法,包括字符串比较、操作及转换等,并对比了String与StringBuilder/StringBuffer的区别,适用于初学者及需要复习相关知识点的开发者。
Object: 所有类的直接或间接父类
toString: 返回对象的字符串表现形式     Object中以地址返回   对象数据类型  @ 地址    子类可以重写成根据内容返回      alt + shift + s  
equals: 比较调用方法的对象与传入的对象是否相同     Object中比较对象地址值   子类可以重写成比较内容   alt + shift + s 

String: 字符串类,字符串是常量;它们的值在创建之后不能更改

构造 new String(char [] chs)、new String(byte [] bys)、new String(StringBuilder sb);   构造可直接将如上常用类型转换为字符串

方法

  ★ boolean equals(Object obj) 判断两个字符串中的内容是否相同
boolean equalsIgnoreCase(String str)  判断两个字符串中的内容是否相同, 忽略大小写
  ★ boolean contains(String str) 判断该字符串中 是否包含给定的字符串
boolean startsWith(String str) 判断该字符串 是否以给定的字符串开头
boolean endsWith(String str) 判断该字符串 是否以给定的字符串结尾
boolean isEmpty() 判断该字符串的内容是否为空的字符串  ""
   ★ int length() 获取该字符串的长度
 ★ String[] split(String regex) 根据给定的正则表达式来拆分字符串 str.split(regex)
char charAt(int index) 获取该字符串中指定位置上的字符 
           ★ String substring(int start) 从指定位置开始,到末尾结束,截取该字符串,返回新字符串
String substring(int start,int end) 从指定位置开始,到指定位置结束,截取该字符串,返回新字符串 
int indexOf(int ch ) 获取给定的字符,在该字符串中第一次出现的位置
int indexOf(String str) 获取给定的字符串,在该字符串中第一次出现的位置
int indexOf(int ch,int fromIndex) 从指定位置开始,获取给定的字符,在该字符
 ★ byte[] getBytes() 把该字符串 转换成 字节数组
char[] toCharArray() 把该字符串 转换成 字符数组
 ★ String replace(char old,char new) 在该字符串中,将给定的旧字符,用新字符替换
String replace(String old,String new) 在该字符串中, 将给定的旧字符串,用新字符串替换
String trim() 去除字符串两端空格,中间的不会去除,返回一个新字符串
String toLowerCase() 把该字符串转换成 小写字符串 
String toUpperCase() 把该字符串转换成 大写字符串
int indexOf(String str,int fromIndex) 从指定位置开始,获取给定的字符串,在该字符串中第一次出现的位置


StringBuffer/StringBuilder:
方法
public StringBuffer append(String str) 在原有字符串缓冲区内容基础上,在末尾追加新数据
public StringBuffer insert(int offset,String str) 在原有字符串缓冲区内容基础上,在指定位置插入新数据
public StringBuffer deleteCharAt(int index) 在原有字符串缓冲区内容基础上,删除指定位置上的字符
public StringBuffer delete(int start,int end) 在原有字符串缓冲区内容基础上,删除指定范围内的多个字符
public StringBuffer replace(int start,int end,String str)在原有字符串缓冲区内容基础上,将指定范围内的多个字符 用给定的字符串替换
    ★ public StringBuffer reverse() 将字符串缓冲区的内容 反转  "abc"----"cba"
      ★ public String substring(int start) 从指定位置开始,到末尾结束,截取该字符串缓冲区,返回新字符串
    ★ public String substring(int start,int end)  从指定位置开始,到指定位置结束,截取该字符串缓冲区,返回新字符串
/* * Copyright 2024-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.dura.common.utils; import org.apache.commons.lang3.StringUtils; import java.time.DayOfWeek; import java.time.LocalDate; import java.time.YearMonth; import java.time.format.DateTimeFormatter; import java.time.temporal.IsoFields; import java.time.temporal.TemporalAdjusters; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; public class DateTimeUtil { public static final Pattern SPECIFIC_YEAR_MONTH_DAY_PATTERN = Pattern.compile("\\d{4}年\\d{2}月\\d{2}日"); public static final Pattern GENERAL_YEAR_MONTH_DAY_PATTERN = Pattern.compile("(今年|去年|前年|明年|后年)(\\d{2}月\\d{2}日)"); public static final Pattern GENERAL_MONTH_DAY_PATTERN = Pattern.compile("(本月|上月|上上月|下月)(\\d{2}日)"); public static final Pattern GENERAL_DAY_PATTERN = Pattern.compile("(今天|昨天|前天|明天|后天|上月今天|上上月今天)"); public static final Pattern WEEK_DAY_PATTERN = Pattern.compile("本周第(\\d)天"); public static final Pattern GENERAL_MONTH_LAST_DAY_PATTERN = Pattern.compile("(本月|上月)最后一天"); public static final Pattern GENERAL_YEAR_MONTH_LAST_DAY_PATTERN = Pattern.compile("(今年)(\\d{2})月最后一天"); public static final Pattern GENERAL_WEEK_SPECIFIC_DAY_PATTERN = Pattern.compile("(本周|上周|上上周|下周|下下周)星期(\\d)"); public static final Pattern SPECIFIC_YEAR_MONTH_PATTERN = Pattern.compile("\\d{4}年\\d{2}月"); public static final Pattern GENERAL_YEAR_MONTH_PATTERN = Pattern.compile("(今年|去年|前年|明年|后年)(\\d{2}月)"); public static final Pattern GENERAL_MONTH_PATTERN = Pattern.compile("(本月|上月|上上月|下月|去年本月)"); public static final Pattern SPECIFIC_YEAR_PATTERN = Pattern.compile("(\\d{4})年"); public static final Pattern GENERAL_YEAR_PATTERN = Pattern.compile("(今年|去年|前年|明年|后年)"); public static final Pattern SPECIFIC_YEAR_QUARTER_PATTERN = Pattern.compile("\\d{4}年第\\d季度"); public static final Pattern GENERAL_YEAR_QUARTER_PATTERN = Pattern.compile("(今年|去年|前年|明年|后年)(第\\d季度)"); public static final Pattern GENERAL_QUARTER_PATTERN = Pattern.compile("(本季度|上季度|下季度|去年本季度)"); public static final Pattern GENERAL_WEEK_PATTERN = Pattern.compile("(本周|上周|上上周|下周|下下周)"); public static final Pattern SPECIFIC_YEAR_WEEK_PATTERN = Pattern.compile("(\\d{4})年第(\\d{2})周"); public static final Pattern SPECIFIC_YEAR_MONTH_WEEK_PATTERN = Pattern.compile("(\\d{4})(\\d{2})月第(\\d)周"); public static final Pattern GENERAL_YEAR_WEEK_PATTERN = Pattern.compile("(今年|去年|前年|明年|后年)(\\d{2})周"); public static final Pattern GENERAL_MONTH_WEEK_PATTERN = Pattern.compile("(本月|上月)(\\d)周"); public static final Pattern GENERAL_YEAR_MONTH_WEEK_PATTERN = Pattern.compile("(今年|去年|前年|明年|后年)(\\d{2})月第(\\d)周"); public static final Pattern SPECIFIC_YEAR_MONTH_LAST_WEEK_PATTERN = Pattern.compile("(\\d{4})(\\d{2})月最后一周"); public static final Pattern GENERAL_MONTH_LAST_WEEK_PATTERN = Pattern.compile("(本月|上月|上上月)最后一周"); public static final Pattern SPECIFIC_YEAR_MONTH_COMPLETE_WEEK_PATTERN = Pattern .compile("(\\d{4})(\\d{2})月第(\\d)个完整周"); public static final Pattern GENERAL_YEAR_COMPLETE_WEEK_PATTERN = Pattern.compile("(今年|去年|前年|明年|后年)(\\d{2})个完整周"); public static final Pattern SPECIFIC_YEAR_COMPLETE_WEEK_PATTERN = Pattern.compile("(\\d{4})年第(\\d{2})个完整周"); public static final Pattern GENERAL_YEAR_MONTH_COMPLETE_WEEK_PATTERN = Pattern .compile("(今年|去年|前年|明年|后年)(\\d{2})月第(\\d)个完整周"); public static final Pattern GENERAL_MONTH_COMPLETE_WEEK_PATTERN = Pattern.compile("(本月|上月)(\\d)个完整周"); public static final Pattern GENERAL_MONTH_LAST_COMPLETE_WEEK_PATTERN = Pattern.compile("(本月|上月|上上月)最后一个完整周"); public static final Pattern RECENT_N_YEAR_PATTERN = Pattern.compile("近(\\d+)年"); public static final Pattern RECENT_N_MONTH_PATTERN = Pattern.compile("近(\\d+)个月"); public static final Pattern RECENT_N_WEEK_PATTERN = Pattern.compile("近(\\d+)周"); public static final Pattern RECENT_N_DAY_PATTERN = Pattern.compile("近(\\d+)天"); public static final Pattern RECENT_N_COMPLETE_YEAR_PATTERN = Pattern.compile("近(\\d+)个完整年"); public static final Pattern RECENT_N_COMPLETE_QUARTER_PATTERN = Pattern.compile("近(\\d+)个完整季度"); public static final Pattern RECENT_N_COMPLETE_MONTH_PATTERN = Pattern.compile("近(\\d+)个完整月"); public static final Pattern RECENT_N_COMPLETE_WEEK_PATTERN = Pattern.compile("近(\\d+)个完整周"); public static final Pattern RECENT_N_DAY_WITHOUT_TODAY_PATTERN = Pattern.compile("不包含今天的近(\\d+)天"); public static final Pattern RECENT_N_QUARTER_WITH_CURRENT_PATTERN = Pattern.compile("包含当前季度的近(\\d+)个季度"); public static final Pattern SPECIFIC_YEAR_HALF_YEAR_PATTERN = Pattern.compile("(\\d{4})(上|下)半年"); public static final Pattern GENERAL_YEAR_HALF_YEAR_PATTERN = Pattern.compile("(今年|去年|前年|明年|后年)(上|下)半年"); public static final Pattern HALF_YEAR_PATTERN = Pattern.compile("(上|下)半年"); public static String buildDateTimeComment(List<String> expressions) { LocalDate now = LocalDate.now(); // Get year, month, day int year = now.getYear(); int month = now.getMonthValue(); int day = now.getDayOfMonth(); // Get current year's quarter int quarter = now.get(IsoFields.QUARTER_OF_YEAR); String todayComment = String.format("今天是%d年%02d月%02d日,是%d年的第%d季度", year, month, day, year, quarter); List<String> dateTimeCommentList = buildDateExpressions(expressions, now); StringBuilder finalExpression = new StringBuilder(); finalExpression.append(todayComment).append("\n"); finalExpression.append("需要计算的时间是:\n"); dateTimeCommentList.forEach(comment -> finalExpression.append(comment).append("\n")); return finalExpression.toString(); } public static List<String> buildDateExpressions(List<String> expressions, LocalDate now) { List<String> dateTimeCommentList = new ArrayList<>(); for (String expression : expressions) { Matcher specificYearMonthDayMatcher = SPECIFIC_YEAR_MONTH_DAY_PATTERN.matcher(expression); if (specificYearMonthDayMatcher.matches()) { dateTimeCommentList.add(expression + "=" + expression); continue; } Matcher generalYearMonthDayMatcher = GENERAL_YEAR_MONTH_DAY_PATTERN.matcher(expression); if (generalYearMonthDayMatcher.matches()) { String yearEx = generalYearMonthDayMatcher.group(1); String comment = getYearEx(now, yearEx, false) + generalYearMonthDayMatcher.group(2); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher generalMonthDayMatcher = GENERAL_MONTH_DAY_PATTERN.matcher(expression); if (generalMonthDayMatcher.matches()) { String monthEx = generalMonthDayMatcher.group(1); String comment = getMonthEx(now, monthEx) + generalMonthDayMatcher.group(2); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher yearMonthLastDayMatcher = GENERAL_YEAR_MONTH_LAST_DAY_PATTERN.matcher(expression); if (yearMonthLastDayMatcher.matches()) { String yearEx = yearMonthLastDayMatcher.group(1); String monthEx = yearMonthLastDayMatcher.group(2); String comment = getGeneralYearMonthLastDayEx(now, yearEx, Integer.valueOf(monthEx)); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher monthLastDayMatcher = GENERAL_MONTH_LAST_DAY_PATTERN.matcher(expression); if (monthLastDayMatcher.matches()) { String monthEx = monthLastDayMatcher.group(1); String comment = getMonthLastDayEx(now, monthEx); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher weekDayMatcher = WEEK_DAY_PATTERN.matcher(expression); if (weekDayMatcher.matches()) { int weekDay = Integer.parseInt(weekDayMatcher.group(1)); String comment = getWeekDayEx(now, weekDay); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher generalWeekDayMatcher = GENERAL_WEEK_SPECIFIC_DAY_PATTERN.matcher(expression); if (generalWeekDayMatcher.matches()) { String weekEx = generalWeekDayMatcher.group(1); int day = Integer.parseInt(generalWeekDayMatcher.group(2)); String comment = getGeneralWeekDayEx(now, weekEx, day); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher specificYearQuarterMatcher = SPECIFIC_YEAR_QUARTER_PATTERN.matcher(expression); if (specificYearQuarterMatcher.matches()) { dateTimeCommentList.add(expression + "=" + expression); continue; } Matcher generalYearQuarterMatcher = GENERAL_YEAR_QUARTER_PATTERN.matcher(expression); if (generalYearQuarterMatcher.matches()) { String yearEx = generalYearQuarterMatcher.group(1); String quarterEx = generalYearQuarterMatcher.group(2); String comment = getYearEx(now, yearEx, false) + quarterEx; dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher generalQuarterMatcher = GENERAL_QUARTER_PATTERN.matcher(expression); if (generalQuarterMatcher.matches()) { String quarterEx = generalQuarterMatcher.group(1); String comment = getQuarterEx(now, quarterEx); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher generalWeekMatcher = GENERAL_WEEK_PATTERN.matcher(expression); if (generalWeekMatcher.matches()) { String weekEx = generalWeekMatcher.group(1); String comment = getWeekEx(now, weekEx); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher specificYearWeekMatcher = SPECIFIC_YEAR_WEEK_PATTERN.matcher(expression); if (specificYearWeekMatcher.matches()) { int yearEx = Integer.parseInt(specificYearWeekMatcher.group(1)); int weekEx = Integer.parseInt(specificYearWeekMatcher.group(2)); String comment = getSpecificYearWeekEx(now, yearEx, weekEx); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher generalYearWeekMatcher = GENERAL_YEAR_WEEK_PATTERN.matcher(expression); if (generalYearWeekMatcher.matches()) { String yearEx = generalYearWeekMatcher.group(1); int weekEx = Integer.parseInt(generalYearWeekMatcher.group(2)); String comment = getGeneralYearWeekEx(now, yearEx, weekEx); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher generalMonthWeekMatcher = GENERAL_MONTH_WEEK_PATTERN.matcher(expression); if (generalMonthWeekMatcher.matches()) { String monthEx = generalMonthWeekMatcher.group(1); int weekEx = Integer.parseInt(generalMonthWeekMatcher.group(2)); String comment = getGeneralMonthWeekEx(now, monthEx, weekEx); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher specificYearMonthLastWeekMatcher = SPECIFIC_YEAR_MONTH_LAST_WEEK_PATTERN.matcher(expression); if (specificYearMonthLastWeekMatcher.matches()) { int yearEx = Integer.parseInt(specificYearMonthLastWeekMatcher.group(1)); int monthEx = Integer.parseInt(specificYearMonthLastWeekMatcher.group(2)); String comment = getSpecificYearMonthLastWeek(now, yearEx, monthEx); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher generalMonthLastWeekMatcher = GENERAL_MONTH_LAST_WEEK_PATTERN.matcher(expression); if (generalMonthLastWeekMatcher.matches()) { String monthEx = generalMonthLastWeekMatcher.group(1); String comment = getGeneralMonthLastWeek(now, monthEx); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher generalMonthLastCompleteWeekMatcher = GENERAL_MONTH_LAST_COMPLETE_WEEK_PATTERN.matcher(expression); if (generalMonthLastCompleteWeekMatcher.matches()) { String monthEx = generalMonthLastCompleteWeekMatcher.group(1); String comment = getGeneralMonthLastCompleteWeekEx(now, monthEx); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher recentNYearMatcher = RECENT_N_YEAR_PATTERN.matcher(expression); if (recentNYearMatcher.matches()) { int n = Integer.parseInt(recentNYearMatcher.group(1)); String comment = getRecentNYear(now, n); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher recentNMonthMatcher = RECENT_N_MONTH_PATTERN.matcher(expression); if (recentNMonthMatcher.matches()) { int n = Integer.parseInt(recentNMonthMatcher.group(1)); String comment = getRecentNMonth(now, n); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher recentNWeekMatcher = RECENT_N_WEEK_PATTERN.matcher(expression); if (recentNWeekMatcher.matches()) { int n = Integer.parseInt(recentNWeekMatcher.group(1)); String comment = getRecentNWeek(now, n); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher recentNDayWithoutTodayMatcher = RECENT_N_DAY_WITHOUT_TODAY_PATTERN.matcher(expression); if (recentNDayWithoutTodayMatcher.matches()) { int n = Integer.parseInt(recentNDayWithoutTodayMatcher.group(1)); String comment = getRecentNDayWithoutToday(now, n); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher recentNDayMatcher = RECENT_N_DAY_PATTERN.matcher(expression); if (recentNDayMatcher.matches()) { int n = Integer.parseInt(recentNDayMatcher.group(1)); String comment = getRecentNDay(now, n); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher recentNCompleteYearMatcher = RECENT_N_COMPLETE_YEAR_PATTERN.matcher(expression); if (recentNCompleteYearMatcher.matches()) { int n = Integer.parseInt(recentNCompleteYearMatcher.group(1)); String comment = getRecentNCompleteYear(now, n); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher recentNCompleteQuarterMatcher = RECENT_N_COMPLETE_QUARTER_PATTERN.matcher(expression); if (recentNCompleteQuarterMatcher.matches()) { int n = Integer.parseInt(recentNCompleteQuarterMatcher.group(1)); String comment = getRecentNCompleteQuarter(now, n); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher recentNCompleteMonthMatcher = RECENT_N_COMPLETE_MONTH_PATTERN.matcher(expression); if (recentNCompleteMonthMatcher.matches()) { int n = Integer.parseInt(recentNCompleteMonthMatcher.group(1)); String comment = getRecentNCompleteMonth(now, n); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher recentNCompleteWeekMatcher = RECENT_N_COMPLETE_WEEK_PATTERN.matcher(expression); if (recentNCompleteWeekMatcher.matches()) { int n = Integer.parseInt(recentNCompleteWeekMatcher.group(1)); String comment = getRecentNCompleteWeek(now, n); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher recentNQuarterWithCurrentMatcher = RECENT_N_QUARTER_WITH_CURRENT_PATTERN.matcher(expression); if (recentNQuarterWithCurrentMatcher.matches()) { int n = Integer.parseInt(recentNQuarterWithCurrentMatcher.group(1)); String comment = getRecentNQuarterWithCurrent(now, n); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher specificYearMonthMatcher = SPECIFIC_YEAR_MONTH_PATTERN.matcher(expression); if (specificYearMonthMatcher.matches()) { dateTimeCommentList.add(expression + "=" + expression); continue; } Matcher generalYearMonthMatcher = GENERAL_YEAR_MONTH_PATTERN.matcher(expression); if (generalYearMonthMatcher.matches()) { String yearEx = generalYearMonthMatcher.group(1); String comment = getYearEx(now, yearEx, false) + generalYearMonthMatcher.group(2); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher generalDayMatcher = GENERAL_DAY_PATTERN.matcher(expression); if (generalDayMatcher.matches()) { String dayEx = generalDayMatcher.group(1); String comment = getDayEx(now, dayEx); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher generalMonthMatcher = GENERAL_MONTH_PATTERN.matcher(expression); if (generalMonthMatcher.matches()) { String monthEx = generalMonthMatcher.group(1); String comment = getMonthEx(now, monthEx); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher specificYearMatcher = SPECIFIC_YEAR_PATTERN.matcher(expression); if (specificYearMatcher.matches()) { int yearEx = Integer.parseInt(specificYearMatcher.group(1)); String comment = String.valueOf(yearEx) + "年"; dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher generalYearMatcher = GENERAL_YEAR_PATTERN.matcher(expression); if (generalYearMatcher.matches()) { String yearEx = generalYearMatcher.group(1); String comment = getYearEx(now, yearEx, true); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher specificYearMonthWeekMatcher = SPECIFIC_YEAR_MONTH_WEEK_PATTERN.matcher(expression); if (specificYearMonthWeekMatcher.matches()) { int yearEx = Integer.parseInt(specificYearMonthWeekMatcher.group(1)); int monthEx = Integer.parseInt(specificYearMonthWeekMatcher.group(2)); int weekEx = Integer.parseInt(specificYearMonthWeekMatcher.group(3)); String comment = getSpecificYearMonthWeekEx(now, yearEx, monthEx, weekEx); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher generalYearMonthWeekMatcher = GENERAL_YEAR_MONTH_WEEK_PATTERN.matcher(expression); if (generalYearMonthWeekMatcher.matches()) { String yearEx = generalYearMonthWeekMatcher.group(1); int monthEx = Integer.parseInt(generalYearMonthWeekMatcher.group(2)); int weekEx = Integer.parseInt(generalYearMonthWeekMatcher.group(3)); String comment = getGeneralYearMonthWeekEx(now, yearEx, monthEx, weekEx); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher specificYearMonthCompleteWeekMatcher = SPECIFIC_YEAR_MONTH_COMPLETE_WEEK_PATTERN .matcher(expression); if (specificYearMonthCompleteWeekMatcher.matches()) { int yearEx = Integer.parseInt(specificYearMonthCompleteWeekMatcher.group(1)); int monthEx = Integer.parseInt(specificYearMonthCompleteWeekMatcher.group(2)); int weekEx = Integer.parseInt(specificYearMonthCompleteWeekMatcher.group(3)); String comment = getSpecificYearMonthCompleteWeekEx(now, yearEx, monthEx, weekEx); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher generalYearMonthCompleteWeekMatcher = GENERAL_YEAR_MONTH_COMPLETE_WEEK_PATTERN.matcher(expression); if (generalYearMonthCompleteWeekMatcher.matches()) { String yearEx = generalYearMonthCompleteWeekMatcher.group(1); int monthEx = Integer.parseInt(generalYearMonthCompleteWeekMatcher.group(2)); int weekEx = Integer.parseInt(generalYearMonthCompleteWeekMatcher.group(3)); String comment = getGeneralYearMonthCompleteWeekEx(now, yearEx, monthEx, weekEx); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher generalMonthCompleteWeekMatcher = GENERAL_MONTH_COMPLETE_WEEK_PATTERN.matcher(expression); if (generalMonthCompleteWeekMatcher.matches()) { String monthEx = generalMonthCompleteWeekMatcher.group(1); int weekEx = Integer.parseInt(generalMonthCompleteWeekMatcher.group(2)); String comment = getGeneralMonthCompleteWeekEx(now, monthEx, weekEx); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher specificYearCompleteWeekMatcher = SPECIFIC_YEAR_COMPLETE_WEEK_PATTERN.matcher(expression); if (specificYearCompleteWeekMatcher.matches()) { int yearEx = Integer.parseInt(specificYearCompleteWeekMatcher.group(1)); int weekEx = Integer.parseInt(specificYearCompleteWeekMatcher.group(2)); String comment = getSpecificYearCompleteWeekEx(now, yearEx, weekEx); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher generalYearCompleteWeekMatcher = GENERAL_YEAR_COMPLETE_WEEK_PATTERN.matcher(expression); if (generalYearCompleteWeekMatcher.matches()) { String yearEx = generalYearCompleteWeekMatcher.group(1); int weekEx = Integer.parseInt(generalYearCompleteWeekMatcher.group(2)); String comment = getGeneralYearCompleteWeekEx(now, yearEx, weekEx); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher specificYearHalfYearMatcher = SPECIFIC_YEAR_HALF_YEAR_PATTERN.matcher(expression); if (specificYearHalfYearMatcher.matches()) { int yearEx = Integer.parseInt(specificYearHalfYearMatcher.group(1)); String halfYearEx = specificYearHalfYearMatcher.group(2); String comment = getSpecificYearHalfYearEx(now, yearEx, halfYearEx); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher generalYearHalfYearMatcher = GENERAL_YEAR_HALF_YEAR_PATTERN.matcher(expression); if (generalYearHalfYearMatcher.matches()) { String yearEx = generalYearHalfYearMatcher.group(1); String halfYearEx = generalYearHalfYearMatcher.group(2); String comment = getGeneralYearHalfYearEx(now, yearEx, halfYearEx); dateTimeCommentList.add(expression + "=" + comment); continue; } Matcher halfYearMatcher = HALF_YEAR_PATTERN.matcher(expression); if (halfYearMatcher.matches()) { String halfYearEx = halfYearMatcher.group(1); String comment = getSpecificYearHalfYearEx(now, now.getYear(), halfYearEx); dateTimeCommentList.add(expression + "=" + comment); continue; } } return dateTimeCommentList; } public static String getYearEx(LocalDate now, String yearEx, boolean applyDomainLogic) { String comment = ""; int year = 0; if (yearEx.equals("今年")) { year = now.getYear(); } else if (yearEx.equals("去年")) { year = now.getYear() - 1; } else if (yearEx.equals("前年")) { year = now.getYear() - 2; } else if (yearEx.equals("明年")) { year = now.getYear() + 1; } else if (yearEx.equals("后年")) { year = now.getYear() + 2; } comment = String.valueOf(year) + "年"; return comment; } public static String getMonthEx(LocalDate now, String monthEx) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月"); String comment = ""; if (monthEx.equals("本月")) { comment = formatter.format(YearMonth.from(now)); } else if (monthEx.equals("上月")) { comment = formatter.format(YearMonth.from(now).minusMonths(1)); } else if (monthEx.equals("上上月")) { comment = formatter.format(YearMonth.from(now).minusMonths(2)); } else if (monthEx.equals("下月")) { comment = formatter.format(YearMonth.from(now).plusMonths(1)); } else if (monthEx.equals("去年本月")) { comment = formatter.format(YearMonth.from(now).minusYears(1)); } return comment; } public static String getDayEx(LocalDate now, String dayEx) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); String comment = ""; try { if (dayEx.equals("今天")) { comment = formatter.format(now); } else if (dayEx.equals("昨天")) { comment = formatter.format(now.minusDays(1)); } else if (dayEx.equals("前天")) { comment = formatter.format(now.minusDays(2)); } else if (dayEx.equals("明天")) { comment = formatter.format(now.plusDays(1)); } else if (dayEx.equals("后天")) { comment = formatter.format(now.plusDays(2)); } else if (dayEx.equals("上月今天")) { comment = formatter.format(YearMonth.from(now).minusMonths(1).atDay(now.getDayOfMonth())); } else if (dayEx.equals("上上月今天")) { comment = formatter.format(YearMonth.from(now).minusMonths(2).atDay(now.getDayOfMonth())); } } catch (Exception e) { e.printStackTrace(); } return comment; } public static final String getWeekDayEx(LocalDate now, int x) { // Calculate date of first day of week (Monday) LocalDate monday = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)); // Get date of xth day of week by adding (x - 1) days LocalDate desiredDay = monday.plusDays(x - 1); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); return formatter.format(desiredDay); } public static final String getGeneralWeekDayEx(LocalDate now, String weekEx, int day) { LocalDate thisMonday = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)); LocalDate desiredDay = thisMonday.plusDays(day - 1); if (weekEx.equals("本周")) { } else if (weekEx.equals("上周")) { desiredDay = desiredDay.minusWeeks(1); } else if (weekEx.equals("上上周")) { desiredDay = desiredDay.minusWeeks(2); } else if (weekEx.equals("下周")) { desiredDay = desiredDay.plusWeeks(1); } else if (weekEx.equals("下下周")) { desiredDay = desiredDay.plusWeeks(2); } DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); return formatter.format(desiredDay); } public static final String getWeekEx(LocalDate now, String weekEx) { LocalDate desireMonday = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)); LocalDate desireSunday = now.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY)); if (weekEx.equals("本周")) { } else if (weekEx.equals("上周")) { desireMonday = desireMonday.minusWeeks(1); desireSunday = desireSunday.minusWeeks(1); } else if (weekEx.equals("上上周")) { desireMonday = desireMonday.minusWeeks(2); desireSunday = desireSunday.minusWeeks(2); } else if (weekEx.equals("下周")) { desireMonday = desireMonday.plusWeeks(1); desireSunday = desireSunday.plusWeeks(1); } else if (weekEx.equals("下下周")) { desireMonday = desireMonday.plusWeeks(2); desireSunday = desireSunday.plusWeeks(2); } DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); return formatter.format(desireMonday) + "至" + formatter.format(desireSunday); } public static String getSpecificYearWeekEx(LocalDate now, int year, int week) { LocalDate firstDayOfYear = LocalDate.of(year, 1, 1); LocalDate targetWeekFirstDay = firstDayOfYear.plusWeeks(week - 1); LocalDate targetWeekLastDay = targetWeekFirstDay.plusDays(6); LocalDate lastDayOfYear = firstDayOfYear.with(TemporalAdjusters.lastDayOfYear()); if (lastDayOfYear.isBefore(targetWeekLastDay)) { targetWeekLastDay = lastDayOfYear; } DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); return formatter.format(targetWeekFirstDay) + "至" + formatter.format(targetWeekLastDay); } public static String getGeneralYearWeekEx(LocalDate now, String yearEx, int week) { int year = now.getYear(); if (yearEx.equals("今年")) { } else if (yearEx.equals("去年")) { year = now.getYear() - 1; } else if (yearEx.equals("前年")) { year = now.getYear() - 2; } else if (yearEx.equals("明年")) { year = now.getYear() + 1; } else if (yearEx.equals("后年")) { year = now.getYear() + 2; } return getSpecificYearWeekEx(now, year, week); } public static String getSpecificYearMonthWeekEx(LocalDate now, int year, int month, int week) { LocalDate firstDayOfMonth = LocalDate.of(year, month, 1); LocalDate targetWeekFirstDay = firstDayOfMonth.plusWeeks(week - 1); LocalDate targetWeekLastDay = targetWeekFirstDay.plusDays(6); LocalDate lastDayOfMonth = firstDayOfMonth.with(TemporalAdjusters.lastDayOfMonth()); if (lastDayOfMonth.isBefore(targetWeekLastDay)) { targetWeekLastDay = lastDayOfMonth; } DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); return formatter.format(targetWeekFirstDay) + "至" + formatter.format(targetWeekLastDay); } public static String getGeneralYearMonthWeekEx(LocalDate now, String yearEx, int month, int week) { int year = now.getYear(); if (yearEx.equals("今年")) { } else if (yearEx.equals("去年")) { year = now.getYear() - 1; } else if (yearEx.equals("前年")) { year = now.getYear() - 2; } else if (yearEx.equals("明年")) { year = now.getYear() + 1; } else if (yearEx.equals("后年")) { year = now.getYear() + 2; } return getSpecificYearMonthWeekEx(now, year, month, week); } public static String getGeneralMonthWeekEx(LocalDate now, String monthEx, int week) { int year = now.getYear(); int month = now.getMonthValue(); if (monthEx.equals("本月")) { } else if (monthEx.equals("上月")) { month = now.getMonthValue() - 1; if (month <= 0) { year--; month = 12 + month; } } LocalDate firstDayOfMonth = LocalDate.of(year, month, 1); LocalDate targetWeekFirstDay = firstDayOfMonth.plusWeeks(week - 1); LocalDate targetWeekLastDay = targetWeekFirstDay.plusDays(6); LocalDate lastDayOfMonth = firstDayOfMonth.with(TemporalAdjusters.lastDayOfMonth()); if (lastDayOfMonth.isBefore(targetWeekLastDay)) { targetWeekLastDay = lastDayOfMonth; } DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); return formatter.format(targetWeekFirstDay) + "至" + formatter.format(targetWeekLastDay); } public static String getSpecificYearMonthCompleteWeekEx(LocalDate now, int year, int month, int week) { LocalDate firstDayOfMonth = LocalDate.of(year, month, 1); LocalDate firstMonday = firstDayOfMonth.with(TemporalAdjusters.firstInMonth(DayOfWeek.MONDAY)); LocalDate targetStartDate = firstMonday.plusWeeks(week - 1); LocalDate targetEndDate = targetStartDate.plusDays(6); LocalDate lastDayOfMonth = firstDayOfMonth.with(TemporalAdjusters.lastDayOfMonth()); if (lastDayOfMonth.isBefore(targetEndDate)) { return StringUtils.EMPTY; } DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); return formatter.format(targetStartDate) + "至" + formatter.format(targetEndDate); } public static String getGeneralYearMonthCompleteWeekEx(LocalDate now, String yearEx, int month, int week) { int year = now.getYear(); if (yearEx.equals("今年")) { } else if (yearEx.equals("去年")) { year = now.getYear() - 1; } else if (yearEx.equals("前年")) { year = now.getYear() - 2; } else if (yearEx.equals("明年")) { year = now.getYear() + 1; } else if (yearEx.equals("后年")) { year = now.getYear() + 2; } return getSpecificYearMonthCompleteWeekEx(now, year, month, week); } public static String getGeneralMonthCompleteWeekEx(LocalDate now, String monthEx, int week) { int year = now.getYear(); int month = now.getMonthValue(); if (monthEx.equals("本月")) { } else if (monthEx.equals("上月")) { month = now.getMonthValue() - 1; if (month <= 0) { year--; month = 12 + month; } } else if (monthEx.equals("上上月")) { month = now.getMonthValue() - 2; if (month <= 0) { year--; month = 12 + month; } } else if (monthEx.equals("下月")) { month = now.getMonthValue() + 1; if (month > 12) { year++; month = month - 12; } } return getSpecificYearMonthCompleteWeekEx(now, year, month, week); } public static String getSpecificYearCompleteWeekEx(LocalDate now, int year, int week) { LocalDate firstDayOfYear = LocalDate.of(year, 1, 1); LocalDate firstMonday = firstDayOfYear.with(TemporalAdjusters.firstInMonth(DayOfWeek.MONDAY)); LocalDate targetStartDate = firstMonday.plusWeeks(week - 1); LocalDate targetEndDate = targetStartDate.plusDays(6); LocalDate lastDayOfYear = firstDayOfYear.with(TemporalAdjusters.lastDayOfYear()); if (lastDayOfYear.isBefore(targetEndDate)) { return StringUtils.EMPTY; } DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); return formatter.format(targetStartDate) + "至" + formatter.format(targetEndDate); } public static String getGeneralYearCompleteWeekEx(LocalDate now, String yearEx, int week) { int year = now.getYear(); if (yearEx.equals("今年")) { } else if (yearEx.equals("去年")) { year = now.getYear() - 1; } else if (yearEx.equals("前年")) { year = now.getYear() - 2; } else if (yearEx.equals("明年")) { year = now.getYear() + 1; } else if (yearEx.equals("后年")) { year = now.getYear() + 2; } return getSpecificYearCompleteWeekEx(now, year, week); } public static String getSpecificYearMonthLastWeek(LocalDate now, int year, int month) { LocalDate firstDayOfMonth = LocalDate.of(year, month, 1); LocalDate lastDayOfMonth = firstDayOfMonth.with(TemporalAdjusters.lastDayOfMonth()); LocalDate previousMonday = lastDayOfMonth.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); return formatter.format(previousMonday) + "至" + formatter.format(lastDayOfMonth); } public static String getGeneralMonthLastWeek(LocalDate now, String monthEx) { int year = now.getYear(); int month = now.getMonthValue(); if (monthEx.equals("本月")) { } else if (monthEx.equals("上月")) { month = now.getMonthValue() - 1; if (month <= 0) { year--; month = 12 + month; } } else if (monthEx.equals("上上月")) { month = now.getMonthValue() - 2; if (month <= 0) { year--; month = 12 + month; } } else if (monthEx.equals("下月")) { month = now.getMonthValue() + 1; if (month > 12) { year++; month = month - 12; } } return getSpecificYearMonthLastWeek(now, year, month); } public static String getSpecificYearMonthLastCompleteWeekEx(LocalDate now, int year, int month) { LocalDate firstDayOfMonth = LocalDate.of(year, month, 1); LocalDate lastSunday = firstDayOfMonth.with(TemporalAdjusters.lastInMonth(DayOfWeek.SUNDAY)); LocalDate lastMonday = lastSunday.minusDays(6); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); return formatter.format(lastMonday) + "至" + formatter.format(lastSunday); } public static String getGeneralMonthLastCompleteWeekEx(LocalDate now, String monthEx) { int year = now.getYear(); int month = now.getMonthValue(); if (monthEx.equals("本月")) { } else if (monthEx.equals("上月")) { month = now.getMonthValue() - 1; if (month <= 0) { year--; month = 12 + month; } } else if (monthEx.equals("上上月")) { month = now.getMonthValue() - 2; if (month <= 0) { year--; month = 12 + month; } } else if (monthEx.equals("下月")) { month = now.getMonthValue() + 1; if (month > 12) { year++; month = month - 12; } } return getSpecificYearMonthLastCompleteWeekEx(now, year, month); } public static String getQuarterEx(LocalDate now, String quarterEx) { int currentQuarter = now.get(IsoFields.QUARTER_OF_YEAR); // Calculate previous and next quarters int lastQuarter = currentQuarter == 1 ? 4 : currentQuarter - 1; int nextQuarter = currentQuarter == 4 ? 1 : currentQuarter + 1; int currentYear = now.getYear(); int yearOfLastQuarter = (currentQuarter == 1) ? currentYear - 1 : currentYear; int yearOfNextQuarter = (currentQuarter == 4) ? currentYear + 1 : currentYear; int yearOfSameQuarterLastYear = currentYear - 1; String comment = ""; if (quarterEx.equals("本季度")) { comment = currentYear + "年第" + currentQuarter + "季度"; } else if (quarterEx.equals("上季度")) { comment = yearOfLastQuarter + "年第" + lastQuarter + "季度"; } else if (quarterEx.equals("下季度")) { comment = yearOfNextQuarter + "年第" + nextQuarter + "季度"; } else if (quarterEx.equals("去年本季度")) { comment = yearOfSameQuarterLastYear + "年第" + currentQuarter + "季度"; } return comment; } public static String getRecentNYear(LocalDate now, int n) { LocalDate startDate = now.minusYears(n); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); return formatter.format(startDate) + "至" + formatter.format(now); } public static String getRecentNMonth(LocalDate now, int n) { LocalDate startDate = now.minusMonths(n); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); return formatter.format(startDate) + "至" + formatter.format(now); } public static String getRecentNWeek(LocalDate now, int n) { LocalDate startDate = now.minusWeeks(n); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); return formatter.format(startDate) + "至" + formatter.format(now); } public static String getRecentNDay(LocalDate now, int n) { LocalDate startDate = now.minusDays(n); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); return formatter.format(startDate) + "至" + formatter.format(now); } public static String getRecentNCompleteYear(LocalDate now, int n) { LocalDate endDate; if (now.getMonthValue() == 12 && now.getDayOfMonth() == 31) { endDate = now; } else { endDate = now.with(TemporalAdjusters.lastDayOfYear()).minusYears(1); } LocalDate startDate = endDate.minusYears(n).plusDays(1); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); return formatter.format(startDate) + "至" + formatter.format(endDate); } public static String getRecentNCompleteMonth(LocalDate now, int n) { LocalDate endDate; if (now.equals(now.with(TemporalAdjusters.lastDayOfMonth()))) { endDate = now; } else { endDate = now.with(TemporalAdjusters.firstDayOfMonth()) .minusMonths(1) .with(TemporalAdjusters.lastDayOfMonth()); } LocalDate startDate = endDate.minusMonths(n).plusDays(1); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); return formatter.format(startDate) + "至" + formatter.format(endDate); } public static String getRecentNCompleteQuarter(LocalDate now, int n) { LocalDate endDate; int currentMonth = now.getMonthValue(); if (currentMonth % 4 == 0 && now.getDayOfMonth() == 31) { endDate = now; } else { if (currentMonth < 4) { endDate = LocalDate.of(now.getYear() - 1, 12, 31); } else if (currentMonth < 7) { endDate = LocalDate.of(now.getYear(), 3, 31); } else if (currentMonth < 10) { endDate = LocalDate.of(now.getYear(), 6, 30); } else { endDate = LocalDate.of(now.getYear(), 9, 30); } } LocalDate startDate = endDate.minusMonths(n * 3).plusDays(1); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); return formatter.format(startDate) + "至" + formatter.format(endDate); } public static String getRecentNCompleteWeek(LocalDate now, int n) { LocalDate endDate; if (now.getDayOfWeek().getValue() == 7) { endDate = now; } else { endDate = now.minusWeeks(1).with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY)); } LocalDate startDate = endDate.minusWeeks(n).plusDays(1); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); return formatter.format(startDate) + "至" + formatter.format(endDate); } public static String getRecentNDayWithoutToday(LocalDate now, int n) { LocalDate startDate = now.minusDays(n); LocalDate endDate = now.minusDays(1); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); return formatter.format(startDate) + "至" + formatter.format(endDate); } public static String getRecentNQuarterWithCurrent(LocalDate now, int n) { LocalDate endDate; int currentMonth = now.getMonthValue(); if (currentMonth < 4) { endDate = LocalDate.of(now.getYear(), 3, 31); } else if (currentMonth < 7) { endDate = LocalDate.of(now.getYear(), 6, 30); } else if (currentMonth < 10) { endDate = LocalDate.of(now.getYear(), 9, 30); } else { endDate = LocalDate.of(now.getYear(), 12, 31); } LocalDate startDate = endDate.minusMonths(n * 3).plusDays(1); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); return formatter.format(startDate) + "至" + formatter.format(endDate); } public static String getMonthLastDayEx(LocalDate now, String monthEx) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); String comment = ""; if (monthEx.equals("本月")) { comment = formatter.format(YearMonth.from(now).atEndOfMonth()); } else if (monthEx.equals("上月")) { comment = formatter.format(YearMonth.from(now).minusMonths(1).atEndOfMonth()); } return comment; } public static String getGeneralYearMonthLastDayEx(LocalDate now, String yearEx, int month) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); String comment = ""; int year = 0; if (yearEx.equals("今年")) { year = now.getYear(); } else if (yearEx.equals("去年")) { year = now.getYear() - 1; } else if (yearEx.equals("前年")) { year = now.getYear() - 2; } else if (yearEx.equals("明年")) { year = now.getYear() + 1; } else if (yearEx.equals("后年")) { year = now.getYear() + 2; } comment = formatter.format(YearMonth.of(year, month).atEndOfMonth()); return comment; } public static String getSpecificYearHalfYearEx(LocalDate now, int year, String halfYearEx) { LocalDate startDate; LocalDate endDate; if (halfYearEx.equals("上")) { startDate = LocalDate.of(year, 1, 1); endDate = LocalDate.of(year, 6, 30); } else { startDate = LocalDate.of(year, 7, 1); endDate = LocalDate.of(year, 12, 31); } DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日"); return formatter.format(startDate) + "至" + formatter.format(endDate); } public static String getGeneralYearHalfYearEx(LocalDate now, String yearEx, String halfYearEx) { int year = 0; if (yearEx.equals("今年")) { year = now.getYear(); } else if (yearEx.equals("去年")) { year = now.getYear() - 1; } else if (yearEx.equals("前年")) { year = now.getYear() - 2; } else if (yearEx.equals("明年")) { year = now.getYear() + 1; } else if (yearEx.equals("后年")) { year = now.getYear() + 2; } return getSpecificYearHalfYearEx(now, year, halfYearEx); } } 这个类在做什么
最新发布
09-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值