Class Almanac

Direct Known Subclasses:
DateKit

public class Almanac extends Converter
日期计算类
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • Almanac

      public Almanac()
  • Method Details

    • getYear

      public static int getYear(Date date)
      获取年,比如2020
      Parameters:
      date - Date
      Returns:
      int
    • getYear

      public static int getYear(Instant instant)
      获取年,比如2020
      Parameters:
      instant - Instant
      Returns:
      int
    • getYear

      public static int getYear(LocalDateTime localDateTime)
      获取年,比如2020 LocalDateTime LocalDate ZonedDateTime 可以直接getYear()
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      int
    • getYear

      public static int getYear(LocalDate localDate)
      获取年,比如2020 LocalDateTime LocalDate ZonedDateTime 可以直接getYear()
      Parameters:
      localDate - localDate
      Returns:
      int
    • getYear

      public static List<String> getYear(String startDate, String endDate)
      获取年份时间段内的所有年
      Parameters:
      startDate - 开始时间
      endDate - 截止时间
      Returns:
      the list
    • getQuarter

      public static LinkedHashSet<String> getQuarter(Date startDate, Date endDate)
      获得指定日期区间内的年份和季节
      Parameters:
      startDate - 起始日期(包含)
      endDate - 结束日期(包含)
      Returns:
      季度列表 ,元素类似于 20132
    • getQuarter

      public static LinkedHashSet<String> getQuarter(long startDate, long endDate)
      获得指定日期区间内的年份和季节
      Parameters:
      startDate - 起始日期(包含)
      endDate - 结束日期(包含)
      Returns:
      季度列表 ,元素类似于 20132
    • getQuarter

      public static Map<String,String> getQuarter(int type, String beginkey, String endkey, String beginWkey, String endWkey, String begin, String end, String beginW, String endW)
      (季度) 计算本期的上期起止时间和同期的起止时间 返回的mao key 时间起止:beginkey endkey 季度起止: beginWkey endWkey 本期的时间起止:begin end 季度:beginW endW type 0本期 1上期 2去年同期 季度
      Parameters:
      type - 计算上期
      beginkey - 开始时间key
      endkey - 截止时间key
      beginWkey - 开始周key
      endWkey - 截止周key
      begin - 开始时间
      end - 截止时间
      beginW - 开始周
      endW - 截止周
      Returns:
      the map
    • getQuarter

      public static List<String> getQuarter(String StartDate, String beginQ, String endDate, String endQ)
      (季度)获取季度份时间段内的所有季度
      Parameters:
      StartDate - 开始日期
      beginQ - 开始季度
      endDate - 截止日期
      endQ - 结束季度
      Returns:
      the list
    • getMonth

      public static String getMonth(int month)
      获取农历月份
      Parameters:
      month - 农历月数值表示
      Returns:
      农历月传统字符表示
    • getMonth

      public static int getMonth(Date date)
      获取月, 比如 1
      Parameters:
      date - Date
      Returns:
      int
    • getMonth

      public static int getMonth(Instant instant)
      获取月, 比如 1
      Parameters:
      instant - Instant
      Returns:
      int
    • getMonth

      public static int getMonth(LocalDateTime localDateTime)
      获取月, 比如 1 LocalDateTime LocalDate ZonedDateTime 可以直接getMonthValue()
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      int
    • getMonth

      public static int getMonth(LocalDate localDate)
      获取月, 比如 1 LocalDateTime LocalDate ZonedDateTime 可以直接getMonthValue()
      Parameters:
      localDate - LocalDate
      Returns:
      int
    • getMonth

      public static List<String> getMonth(String startDate, String endDate)
      当时间段内的所有月份
      Parameters:
      startDate - 开始日期
      endDate - 结束日期
      Returns:
      the list
    • getMonth

      public static Map<String,String> getMonth(int type, String beginkey, String endkey, String begin, String end)
      (月)计算本期的上期和去年同期 1 上期 2同期 返回的mapkay beginkey endkey 本期起止:begin end 计算上期的起止时间 和去年同期 type 0本期 1上期 2去年同期
      Parameters:
      type - 计算上期
      beginkey - 开始时间key
      endkey - 截止时间key
      begin - 开始时间
      end - 截止时间
      Returns:
      the map
    • getMonthEnLong

      public static String getMonthEnLong(Date date)
      获取月英文全称, 比如 January
      Parameters:
      date - Date
      Returns:
      String
    • getMonthEnLong

      public static String getMonthEnLong(Instant instant)
      获取月英文全称, 比如 January
      Parameters:
      instant - Instant
      Returns:
      String
    • getMonthEnLong

      public static String getMonthEnLong(LocalDateTime localDateTime)
      获取月英文全称, 比如 January
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      String
    • getMonthEnLong

      public static String getMonthEnLong(LocalDate localDate)
      获取月英文全称, 比如 January
      Parameters:
      localDate - LocalDate
      Returns:
      String
    • getMonthEnShort

      public static String getMonthEnShort(Date date)
      获取月英文简称, 比如 Jan
      Parameters:
      date - Date
      Returns:
      String
    • getMonthEnShort

      public static String getMonthEnShort(Instant instant)
      获取月英文简称, 比如 Jan
      Parameters:
      instant - Instant
      Returns:
      String
    • getMonthEnShort

      public static String getMonthEnShort(LocalDateTime localDateTime)
      获取月英文简称, 比如 Jan
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      String
    • getMonthEnShort

      public static String getMonthEnShort(LocalDate localDate)
      获取月英文简称, 比如 Jan
      Parameters:
      localDate - LocalDate
      Returns:
      String
    • getMonthEnShortUpper

      public static String getMonthEnShortUpper(Date date)
      获取月英文简称大写, 比如 JAN
      Parameters:
      date - Date
      Returns:
      String
    • getMonthEnShortUpper

      public static String getMonthEnShortUpper(Instant instant)
      获取月英文简称大写, 比如 JAN
      Parameters:
      instant - Instant
      Returns:
      String
    • getMonthEnShortUpper

      public static String getMonthEnShortUpper(LocalDateTime localDateTime)
      获取月英文简称大写, 比如 JAN
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      String
    • getMonthEnShortUpper

      public static String getMonthEnShortUpper(LocalDate localDate)
      获取月英文简称大写, 比如 JAN
      Parameters:
      localDate - LocalDate
      Returns:
      String
    • getMonthCnLong

      public static String getMonthCnLong(Date date)
      获取月份中文全称, 比如一月
      Parameters:
      date - Date
      Returns:
      String
    • getMonthCnLong

      public static String getMonthCnLong(Instant instant)
      获取月份中文全称, 比如一月
      Parameters:
      instant - Instant
      Returns:
      String
    • getMonthCnLong

      public static String getMonthCnLong(LocalDateTime localDateTime)
      获取月份中文全称, 比如一月
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      String
    • getMonthCnLong

      public static String getMonthCnLong(LocalDate localDate)
      获取月份中文全称, 比如一月
      Parameters:
      localDate - LocalDate
      Returns:
      String
    • getMonthCnShort

      public static String getMonthCnShort(Date date)
      获取月份中文简称, 比如一
      Parameters:
      date - Date
      Returns:
      String
    • getMonthCnShort

      public static String getMonthCnShort(Instant instant)
      获取月份中文简称, 比如一
      Parameters:
      instant - Instant
      Returns:
      String
    • getMonthCnShort

      public static String getMonthCnShort(LocalDateTime localDateTime)
      获取月份中文简称, 比如一
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      String
    • getMonthCnShort

      public static String getMonthCnShort(LocalDate localDate)
      获取月份中文简称, 比如一
      Parameters:
      localDate - LocalDate
      Returns:
      String
    • getMonthOfQuarter

      public static int getMonthOfQuarter(int quarter)
      根据季度返回季度第一月
      Parameters:
      quarter - 季度
      Returns:
      月份
    • getMonthOfQuarter

      public static String getMonthOfQuarter(int type, int quarter)
      根据季度返回季度第一月或最后一月 0 起始月 1截止月
      Parameters:
      type - 第一个月份
      quarter - 季度
      Returns:
      月份
    • getQuarterOfMonth

      public static int getQuarterOfMonth(int month)
      根据月份获取所在季度
      Parameters:
      month - 月份
      Returns:
      季度
    • getWeek

      public static List<String> getWeek(String begin, String end, String startw, String endW)
      (周)返回起止时间内的所有自然周
      Parameters:
      begin - 时间起
      end - 时间止
      startw - 周起
      endW - 周止
      Returns:
      the list
    • getWeek

      public static int getWeek(String year)
      返回该年有多少个自然周
      Parameters:
      year - 最多53 一般52 如果12月月末今天在本年53周(属于第二年第一周) 那么按照当年52周算
      Returns:
      the int
    • getWeek

      public static int getWeek(Date start, Date end)
      获取两个日期段相差的周数
      Parameters:
      start - 日期
      end - 日期
      Returns:
      the int
    • getDayOfMonth

      public static String getDayOfMonth(int lunarDay)
      获取农历日的表示
      Parameters:
      lunarDay - 农历日数值表示
      Returns:
      农历日传统字符表示
    • getDayOfMonth

      public static int getDayOfMonth(int month, boolean isLeapYear)
      获得指定月份的总天数
      Parameters:
      month - 月份
      isLeapYear - 是否闰年
      Returns:
    • getDayOfMonth

      public static int getDayOfMonth(Date date)
      获取天
      Parameters:
      date - Date
      Returns:
      int
    • getDayOfMonth

      public static int getDayOfMonth(Instant instant)
      获取天
      Parameters:
      instant - Instant
      Returns:
      int
    • getDayOfMonth

      public static int getDayOfMonth(LocalDateTime localDateTime)
      获取天 LocalDateTime LocalDate ZonedDateTime 可以直接.getDayOfMonth()
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      int
    • getDayOfMonth

      public static int getDayOfMonth(LocalDate localDate)
      获取天 LocalDateTime LocalDate ZonedDateTime 可以直接.getDayOfMonth()
      Parameters:
      localDate - localDate
      Returns:
      int
    • getDayOfYear

      public static int getDayOfYear(Date date)
      获取天(一年中)
      Parameters:
      date - Date
      Returns:
      int
    • getDayOfYear

      public static int getDayOfYear(Instant instant)
      获取天(一年中)
      Parameters:
      instant - Instant
      Returns:
      int
    • getDayOfYear

      public static int getDayOfYear(LocalDateTime localDateTime)
      获取天(一年中) LocalDateTime LocalDate ZonedDateTime 可以直接.getDayOfYear()获取
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      int
    • getDayOfYear

      public static int getDayOfYear(LocalDate localDate)
      获取天(一年中) LocalDateTime LocalDate ZonedDateTime 可以直接.getDayOfYear()获取
      Parameters:
      localDate - localDate
      Returns:
      int
    • getLengthOfYear

      public static int getLengthOfYear(int year)
      获取某年的总天数
      Parameters:
      year - 年
      Returns:
      int
    • getDayOfYear

      public static int getDayOfYear()
      获取当前时间在一年中的第几天
      Returns:
      int
    • getHour

      public static int getHour(Date date)
      获取小时
      Parameters:
      date - Date
      Returns:
      int
    • getHour

      public static int getHour(Instant instant)
      获取小时
      Parameters:
      instant - Instant
      Returns:
      int
    • getHour

      public static int getHour(LocalDateTime localDateTime)
      获取小时 LocalDateTime LocalTime ZonedDateTime 可以直接.getHour()获取
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      int
    • getHour

      public static int getHour(LocalTime localTime)
      获取小时 LocalDateTime LocalTime ZonedDateTime 可以直接.getHour()获取
      Parameters:
      localTime - localTime
      Returns:
      int
    • getMinute

      public static int getMinute(Date date)
      获取分钟
      Parameters:
      date - Date
      Returns:
      int
    • getMinute

      public static int getMinute(Instant instant)
      获取分钟
      Parameters:
      instant - Instant
      Returns:
      int
    • getMinute

      public static int getMinute(LocalDateTime localDateTime)
      获取分钟 LocalDateTime LocalTime ZonedDateTime 可以直接.getMinute()获取
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      int
    • getMinute

      public static int getMinute(LocalTime localTime)
      获取分钟 LocalDateTime LocalTime ZonedDateTime 可以直接.getMinute()获取
      Parameters:
      localTime - localTime
      Returns:
      int
    • getSecond

      public static int getSecond(Date date)
      获取秒
      Parameters:
      date - Date
      Returns:
      int
    • getSecond

      public static int getSecond(Instant instant)
      获取秒
      Parameters:
      instant - Instant
      Returns:
      int
    • getSecond

      public static int getSecond(LocalDateTime localDateTime)
      获取秒 LocalDateTime LocalTime ZonedDateTime 可以直接.getSecond()获取
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      int
    • getSecond

      public static int getSecond(LocalTime localTime)
      获取秒 LocalDateTime LocalTime ZonedDateTime 可以直接.getSecond()获取
      Parameters:
      localTime - localTime
      Returns:
      int
    • getMillisecond

      public static int getMillisecond(Date date)
      获取毫秒
      Parameters:
      date - Date
      Returns:
      int
    • getMillisecond

      public static int getMillisecond(Instant instant)
      获取毫秒
      Parameters:
      instant - Instant
      Returns:
      int
    • getMillisecond

      public static int getMillisecond(LocalDateTime localDateTime)
      获取毫秒
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      int
    • getMillisecond

      public static int getMillisecond(LocalTime localTime)
      获取毫秒
      Parameters:
      localTime - localTime
      Returns:
      int
    • getMillisecond

      public static int getMillisecond(ZonedDateTime zonedDateTime)
      获取毫秒
      Parameters:
      zonedDateTime - zonedDateTime
      Returns:
      int
    • getEpochMilli

      public static long getEpochMilli()
      获取时间戳
      Returns:
      long
    • getEpochSecond

      public static long getEpochSecond()
      获取时间戳(到秒)
      Returns:
      long
    • getEpochMilliFormat

      public static String getEpochMilliFormat()
      获取格式化时间戳字符串
      Returns:
      String 格式: yyyy-MM-dd HH:mm:ss
    • getEpochMilliFormatFull

      public static String getEpochMilliFormatFull()
      获取格式化时间戳字符串,带毫秒
      Returns:
      String 格式: yyyy-MM-dd HH:mm:ss.SSS
    • getEpochMilliIsoNotFormatNoColon

      public static String getEpochMilliIsoNotFormatNoColon()
      获取格式化时间戳字符串 iso格式 2020-02-18T22:37:55+0800
      Returns:
      String 格式: yyyy-MM-ddTHH:mm:ssZ
    • getEpochMilliIsoFormatFullNoColon

      public static String getEpochMilliIsoFormatFullNoColon()
      获取格式化时间戳字符串 iso格式 带毫秒 2020-02-18T22:37:55.991+0800
      Returns:
      String 格式: yyyy-MM-dd'T'HH:mm:ss.SSSZ
    • getDate

      public static Date getDate(int year, int month, int dayOfMonth)
      根据年月日创建Date,时间部分为:00:00:00
      Parameters:
      year - 年
      month - 月
      dayOfMonth - 日
      Returns:
      Date
    • getDate

      public static Date getDate(int year, int month, int dayOfMonth, int hour, int minute, int second)
      根据年月日时分秒创建Date
      Parameters:
      year - 年
      month - 月
      dayOfMonth - 日
      hour - 时
      minute - 分
      second - 秒
      Returns:
      Date
    • getDate

      public static Date getDate(int year, int month, int dayOfMonth, int hour, int minute, int second, int milliOfSecond)
      根据年月日时分秒毫秒创建Date
      Parameters:
      year - 年
      month - 月
      dayOfMonth - 日
      hour - 时
      minute - 分
      second - 秒
      milliOfSecond - 毫秒
      Returns:
      Date
    • getDateStartOfMonth

      public static Date getDateStartOfMonth(int year, int month)
      获取指定月第一天
      Parameters:
      year - 年
      month - 月
      Returns:
      Date
    • getDateEndOfMonth

      public static Date getDateEndOfMonth(int year, int month)
      获取指定月最后一天
      Parameters:
      year - 年
      month - 月
      Returns:
      Date
    • getAge

      public static int getAge(LocalDate birthDay)
      计算年龄
      Parameters:
      birthDay - 生日
      Returns:
      int 年龄
    • getAge

      public static int getAge(Date birthDay)
      计算年龄
      Parameters:
      birthDay - 生日
      Returns:
      int 年龄
    • getAge

      public static int getAge(LocalDateTime birthDay)
      计算年龄
      Parameters:
      birthDay - 生日
      Returns:
      int 年龄
    • getAge

      public static int getAge(String birthday)
      出生日期转年龄
      Parameters:
      birthday - 时间戳字符串
      Returns:
      int 年龄
    • getAge

      public static int getAge(Date birthday, Date dateToCompare)
      计算相对于dateToCompare的年龄,长用于计算指定生日在某年的年龄
      Parameters:
      birthday - 生日
      dateToCompare - 需要对比的日期
      Returns:
      年龄
    • getAge

      public static int getAge(Calendar birthday, Calendar dateToCompare)
      计算相对于dateToCompare的年龄,长用于计算指定生日在某年的年龄
      Parameters:
      birthday - 生日
      dateToCompare - 需要对比的日期
      Returns:
      年龄
    • getAge

      public static int getAge(long birthDay, long dateToCompare)
      计算相对于dateToCompare的年龄,长用于计算指定生日在某年的年龄
      Parameters:
      birthDay - 生日
      dateToCompare - 需要对比的日期
      Returns:
      年龄
    • getAge

      public static String getAge(String birthDay, String dateToCompare)
      计算年龄, 返回几周岁几个月几天
      Parameters:
      birthDay - 出生日期:yyyy-MM-dd
      dateToCompare - 对比日期: yyyy-MM-dd, 默认当前系统日期
      Returns:
      java.lang.String 返回几周岁几个月几天: 如 6 岁 3 个月 2 天
    • getQuarter

      public static int getQuarter(LocalDateTime localDateTime)
      获得季度值
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      int 季度 1,2,3,4
    • getQuarter

      public static int getQuarter(LocalDate localDate)
      获得季度值
      Parameters:
      localDate - LocalDate
      Returns:
      int 季度 1,2,3,4
    • getQuarter

      public static int getQuarter(Date date)
      获得季度值
      Parameters:
      date - Date
      Returns:
      int 季度 1,2,3,4
    • getQuarter

      public static int getQuarter()
      获得当前季度值
      Returns:
      int 季度 1,2,3,4
    • getLast

      public static Map<String,String> getLast(int type, String beginkey, String endkey, String begin, String end)
      计算去年同期和上期的起止时间
      Parameters:
      type - 计算上期
      beginkey - 开始时间key
      endkey - 截止时间key
      begin - 开始时间
      end - 截止时间
      Returns:
      the map
    • getLast

      public static List<String> getLast(String begin, String end)
      计算时间段内的所有的天 type:0本期1上期2去年同期
      Parameters:
      begin - 起始日期
      end - 截止日期
      Returns:
      the list
    • getLast

      public static Map<String,String> getLast(int type, String beginkey, String endkey, String beginWkey, String endWkey, String begin, String end, String beginW, String endW)
      (周)计算(周) 上期和去年同期的起止日期和起止周 计算上期的起止时间 和去年同期 type 0本期 1上期 2去年同期 起始日期key beginkey endkey 起始日期的起止周key beginWkey endWkey 本期:begin end 本期起止周 beginW、endW
      Parameters:
      type - 计算上期
      beginkey - 开始时间key
      endkey - 截止时间key
      beginWkey - 开始周key
      endWkey - 截止周key
      begin - 开始时间
      end - 截止时间
      beginW - 开始周
      endW - 截止周
      Returns:
      the map
    • getLast

      public static Map<String,String> getLast(String beginkey, String endkey, String begin, String end)
      (年)计算本期(年)的上期
      Parameters:
      beginkey - 开始时间key
      endkey - 截止时间key
      begin - 开始时间
      end - 截止时间
      Returns:
      the map
    • getInterval

      public static int getInterval(Date start, Date end)
      获取两个日期段相差的周数
      Parameters:
      start - 日期
      end - 日期
      Returns:
      the int
    • getWeeks

      public static int getWeeks(Date start, Date end)
      计算指定指定时间区间内的周数
      Parameters:
      start - 开始时间
      end - 结束时间
      Returns:
      周数
    • withYear

      public static Date withYear(Date date, long newValue)
      修改年
      Parameters:
      date - Date
      newValue - 新值
      Returns:
      Date
    • withYear

      public static LocalDateTime withYear(LocalDateTime localDateTime, long newValue)
      修改年
      Parameters:
      localDateTime - LocalDateTime
      newValue - 新值
      Returns:
      LocalDateTime
    • withYear

      public static LocalDate withYear(LocalDate localDate, long newValue)
      修改年
      Parameters:
      localDate - LocalDate
      newValue - 新值
      Returns:
      LocalDate
    • withYear

      public static Date withYear(Date date, int newValue)
      原有时间基础上,加上/减去(负数)N年
      Parameters:
      date - 日期
      newValue - 年份
      Returns:
      操作后的时间
    • withMonth

      public static LocalDateTime withMonth(LocalDateTime localDateTime, long newValue)
      修改月
      Parameters:
      localDateTime - LocalDateTime
      newValue - 新值
      Returns:
      LocalDateTime
    • withMonth

      public static LocalDate withMonth(LocalDate localDate, long newValue)
      修改月
      Parameters:
      localDate - LocalDate
      newValue - 新值
      Returns:
      LocalDate
    • withMonth

      public static Date withMonth(Date date, int newValue)
      原有时间基础上,加上/减去(负数)N月
      Parameters:
      date - 日期
      newValue - 月份
      Returns:
      操作后的时间
    • withWeek

      public static Date withWeek(Date date, int newValue)
      原有时间基础上,加上/减去(负数)N周
      Parameters:
      date - 日期
      newValue - 周
      Returns:
      操作后的时间
    • withDay

      public static Date withDay(Date date, int newValue)
      原有时间基础上,加上/减去(负数)N天
      Parameters:
      date - 日期
      newValue - 天
      Returns:
      操作后的时间
    • withHour

      public static Date withHour(Date date, long newValue)
      修改小时
      Parameters:
      date - Date
      newValue - 新值
      Returns:
      Date
    • withHour

      public static LocalDateTime withHour(LocalDateTime localDateTime, long newValue)
      修改小时
      Parameters:
      localDateTime - LocalDateTime
      newValue - 新值
      Returns:
      LocalDateTime
    • withHour

      public static LocalTime withHour(LocalTime localTime, long newValue)
      修改小时
      Parameters:
      localTime - LocalTime
      newValue - 新值
      Returns:
      LocalTime
    • withHour

      public static Date withHour(Date date, int newValue)
      原有时间基础上,加上/减去(负数)N小时
      Parameters:
      date - 日期
      newValue - 小时
      Returns:
      操作后的时间
    • withMinute

      public static Date withMinute(Date date, long newValue)
      修改分钟
      Parameters:
      date - Date
      newValue - 新值
      Returns:
      Date
    • withMinute

      public static LocalDateTime withMinute(LocalDateTime localDateTime, long newValue)
      修改分钟
      Parameters:
      localDateTime - LocalDateTime
      newValue - 新值
      Returns:
      LocalDateTime
    • withMinute

      public static LocalTime withMinute(LocalTime localTime, long newValue)
      修改分钟
      Parameters:
      localTime - LocalTime
      newValue - 新值
      Returns:
      LocalTime
    • withMinute

      public static Date withMinute(Date date, int newValue)
      原有时间基础上,加上/减去(负数)N分钟
      Parameters:
      date - 日期
      newValue - 分钟
      Returns:
      操作后的时间
    • withSecond

      public static Date withSecond(Date date, long newValue)
      修改秒
      Parameters:
      date - Date
      newValue - 新值
      Returns:
      Date
    • withSecond

      public static LocalDateTime withSecond(LocalDateTime localDateTime, long newValue)
      修改秒
      Parameters:
      localDateTime - LocalDateTime
      newValue - 新值
      Returns:
      LocalDateTime
    • withSecond

      public static LocalTime withSecond(LocalTime localTime, long newValue)
      修改秒
      Parameters:
      localTime - LocalTime
      newValue - 新值
      Returns:
      LocalTime
    • withSecond

      public static Date withSecond(Date date, int newValue)
      原有时间基础上,加上/减去(负数)N秒
      Parameters:
      date - 日期
      newValue - 秒
      Returns:
      操作后的时间
    • withMilli

      public static Date withMilli(Date date, long newValue)
      修改毫秒
      Parameters:
      date - Date
      newValue - 新值
      Returns:
      Date
    • withMilli

      public static LocalDateTime withMilli(LocalDateTime localDateTime, long newValue)
      修改毫秒
      Parameters:
      localDateTime - LocalDateTime
      newValue - 新值
      Returns:
      LocalDateTime
    • withMilli

      public static LocalTime withMilli(LocalTime localTime, long newValue)
      修改毫秒
      Parameters:
      localTime - LocalTime
      newValue - 新值
      Returns:
      LocalTime
    • withMilli

      public static Date withMilli(Date date, int newValue)
      原有时间基础上,加上/减去(负数)N毫秒
      Parameters:
      date - 日期
      newValue - 毫秒
      Returns:
      操作后的时间
    • withDayOfMonth

      public static Date withDayOfMonth(Date date, long newValue)
      修改天
      Parameters:
      date - Date
      newValue - 新值
      Returns:
      Date
    • withDayOfMonth

      public static LocalDateTime withDayOfMonth(LocalDateTime localDateTime, long newValue)
      修改天
      Parameters:
      localDateTime - LocalDateTime
      newValue - 新值
      Returns:
      LocalDateTime
    • withDayOfMonth

      public static LocalDate withDayOfMonth(LocalDate localDate, long newValue)
      修改天
      Parameters:
      localDate - LocalDate
      newValue - 新值
      Returns:
      LocalDate
    • withDayOfYear

      public static Date withDayOfYear(Date date, long newValue)
      修改一年中的天
      Parameters:
      date - Date
      newValue - 新值
      Returns:
      Date
    • withDayOfYear

      public static LocalDateTime withDayOfYear(LocalDateTime localDateTime, long newValue)
      修改一年中的天
      Parameters:
      localDateTime - LocalDateTime
      newValue - 新值
      Returns:
      LocalDateTime
    • withDayOfYear

      public static LocalDate withDayOfYear(LocalDate localDate, long newValue)
      修改一年中的天
      Parameters:
      localDate - LocalDate
      newValue - 新值
      Returns:
      LocalDate
    • withDayOfWeek

      public static Date withDayOfWeek(Date date, long newValue)
      修改星期
      Parameters:
      date - Date
      newValue - 新值 1-7
      Returns:
      Date
    • withDayOfWeek

      public static LocalDateTime withDayOfWeek(LocalDateTime localDateTime, long newValue)
      修改星期
      Parameters:
      localDateTime - LocalDateTime
      newValue - 新值 1-7
      Returns:
      LocalDateTime
    • withDayOfWeek

      public static LocalDate withDayOfWeek(LocalDate localDate, long newValue)
      修改星期
      Parameters:
      localDate - LocalDate
      newValue - 新值 1-7
      Returns:
      LocalDateTime
    • betweenYears

      public static long betweenYears(LocalDateTime startInclusive, LocalDateTime endExclusive)
      获取2个日期的相差年月天的年数 比如2020-02-29 2021-03-07,返回1
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenYears

      public static long betweenYears(Date startInclusive, Date endExclusive)
      获取2个日期的相差年月天的年数 比如2020-02-29 2021-03-07,返回1
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenYears

      public static long betweenYears(LocalDate startInclusive, LocalDate endExclusive)
      获取2个日期的相差年月天的年数 比如2020-02-29 2021-03-07,返回1
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenMonths

      public static long betweenMonths(LocalDateTime startInclusive, LocalDateTime endExclusive)
      获取2个日期的相差年月天的月数 比如2020-02-29 2021-03-07,返回0
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenMonths

      public static long betweenMonths(Date startInclusive, Date endExclusive)
      获取2个日期的相差年月天的月数 比如2020-02-29 2021-03-07,返回0
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenMonths

      public static long betweenMonths(LocalDate startInclusive, LocalDate endExclusive)
      获取2个日期的相差年月天的月数 比如2020-02-29 2021-03-07,返回0
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenDays

      public static long betweenDays(LocalDateTime startInclusive, LocalDateTime endExclusive)
      获取2个日期的相差年月天的天数 比如2020-02-29 2021-03-07,返回7
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenDays

      public static long betweenDays(Date startInclusive, Date endExclusive)
      获取2个日期的相差年月天的天数 比如2020-02-29 2021-03-06,返回6
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenDays

      public static long betweenDays(LocalDate startInclusive, LocalDate endExclusive)
      获取2个日期的相差年月天的天数 比如2020-02-29 2021-03-06,返回6
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenTotalDays

      public static long betweenTotalDays(LocalDateTime startInclusive, LocalDateTime endExclusive)
      获取2个日期的相差总天数
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenTotalDays

      public static long betweenTotalDays(Date startInclusive, Date endExclusive)
      获取2个日期的相差总天数
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenTotalHours

      public static long betweenTotalHours(LocalDateTime startInclusive, LocalDateTime endExclusive)
      获取2个日期的相差总小时数
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenTotalHours

      public static long betweenTotalHours(LocalTime startInclusive, LocalTime endExclusive)
      获取2个日期的相差总小时数
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenTotalHours

      public static long betweenTotalHours(Date startInclusive, Date endExclusive)
      获取2个日期的相差总小时数
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenTotalMinutes

      public static long betweenTotalMinutes(LocalDateTime startInclusive, LocalDateTime endExclusive)
      获取2个日期的相差总分钟数
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenTotalMinutes

      public static long betweenTotalMinutes(LocalTime startInclusive, LocalTime endExclusive)
      获取2个日期的相差总分钟数
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenTotalMinutes

      public static long betweenTotalMinutes(Date startInclusive, Date endExclusive)
      获取2个日期的相差总分钟数
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenTotalSeconds

      public static long betweenTotalSeconds(LocalDateTime startInclusive, LocalDateTime endExclusive)
      获取2个日期的相差总秒数
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenTotalSeconds

      public static long betweenTotalSeconds(LocalTime startInclusive, LocalTime endExclusive)
      获取2个日期的相差总秒数
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenTotalSeconds

      public static long betweenTotalSeconds(Date startInclusive, Date endExclusive)
      获取2个日期的相差总秒数
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenTotalMillis

      public static long betweenTotalMillis(LocalDateTime startInclusive, LocalDateTime endExclusive)
      获取2个日期的相差总毫秒数
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenTotalMillis

      public static long betweenTotalMillis(LocalTime startInclusive, LocalTime endExclusive)
      获取2个日期的相差总毫秒数
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenTotalMillis

      public static long betweenTotalMillis(Date startInclusive, Date endExclusive)
      获取2个日期的相差总毫秒数
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenTotalNanos

      public static long betweenTotalNanos(LocalDateTime startInclusive, LocalDateTime endExclusive)
      获取2个日期的相差总纳秒数
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenTotalNanos

      public static long betweenTotalNanos(LocalTime startInclusive, LocalTime endExclusive)
      获取2个日期的相差总纳秒数
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • betweenTotalNanos

      public static long betweenTotalNanos(Date startInclusive, Date endExclusive)
      获取2个日期的相差总纳秒数
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      long
    • getDayOfWeek

      public static int getDayOfWeek(Date date)
      获取星期值 1-7,星期一到星期日
      Parameters:
      date - Date
      Returns:
      int
    • getDayOfWeek

      public static int getDayOfWeek(LocalDateTime localDateTime)
      获取星期值 1-7,星期一到星期日
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      int
    • getDayOfWeek

      public static int getDayOfWeek(LocalDate localDate)
      获取星期值 1-7,星期一到星期日
      Parameters:
      localDate - LocalDate
      Returns:
      int
    • getDayOfWeek

      public static int getDayOfWeek(Instant instant)
      获取星期值 1-7,星期一到星期日
      Parameters:
      instant - Instant
      Returns:
      int
    • getDayOfWeekEnLong

      public static String getDayOfWeekEnLong(Date date)
      获取星期英文全称,比如Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday
      Parameters:
      date - Date
      Returns:
      String
    • getDayOfWeekEnLong

      public static String getDayOfWeekEnLong(LocalDateTime localDateTime)
      获取星期英文全称,比如Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      String
    • getDayOfWeekEnLong

      public static String getDayOfWeekEnLong(LocalDate localDate)
      获取星期英文全称,比如Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday
      Parameters:
      localDate - LocalDate
      Returns:
      String
    • getDayOfWeekEnLong

      public static String getDayOfWeekEnLong(Instant instant)
      获取星期英文全称,比如Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday
      Parameters:
      instant - Instant
      Returns:
      String
    • getDayOfWeekEnShort

      public static String getDayOfWeekEnShort(Date date)
      获取星期英文简称,比如Mon
      Parameters:
      date - Date
      Returns:
      String
    • getDayOfWeekEnShort

      public static String getDayOfWeekEnShort(LocalDateTime localDateTime)
      获取星期英文简称,比如Mon
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      String
    • getDayOfWeekEnShort

      public static String getDayOfWeekEnShort(LocalDate localDate)
      获取星期英文简称,比如Mon
      Parameters:
      localDate - LocalDate
      Returns:
      String
    • getDayOfWeekEnShort

      public static String getDayOfWeekEnShort(Instant instant)
      获取星期英文简称,比如Mon
      Parameters:
      instant - Instant
      Returns:
      String
    • getDayOfWeekEnShortUpper

      public static String getDayOfWeekEnShortUpper(Date date)
      获取星期英文简称大写,比如MON
      Parameters:
      date - Date
      Returns:
      String
    • getDayOfWeekEnShortUpper

      public static String getDayOfWeekEnShortUpper(LocalDateTime localDateTime)
      获取星期英文简称大写,比如MON
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      String
    • getDayOfWeekEnShortUpper

      public static String getDayOfWeekEnShortUpper(LocalDate localDate)
      获取星期英文简称大写,比如MON
      Parameters:
      localDate - LocalDate
      Returns:
      String
    • getDayOfWeekEnShortUpper

      public static String getDayOfWeekEnShortUpper(Instant instant)
      获取星期英文简称大写,比如MON
      Parameters:
      instant - Instant
      Returns:
      String
    • getDayOfWeekCn

      public static String getDayOfWeekCn(Date date)
      获取星期中文,比如星期一
      Parameters:
      date - Date
      Returns:
      String
    • getDayOfWeekCn

      public static String getDayOfWeekCn(LocalDateTime localDateTime)
      获取星期中文,比如星期一
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      String
    • getDayOfWeekCn

      public static String getDayOfWeekCn(LocalDate localDate)
      获取星期中文,比如星期一
      Parameters:
      localDate - LocalDate
      Returns:
      String
    • getDayOfWeekCn

      public static String getDayOfWeekCn(Instant instant)
      获取星期中文,比如星期一
      Parameters:
      instant - Instant
      Returns:
      String
    • getDayOfWeekCnShort

      public static String getDayOfWeekCnShort(Date date)
      获取星期中文简称,比如星期一为一
      Parameters:
      date - Date
      Returns:
      String
    • getDayOfWeekCnShort

      public static String getDayOfWeekCnShort(LocalDateTime localDateTime)
      获取星期中文简称,比如星期一为一
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      String
    • getDayOfWeekCnShort

      public static String getDayOfWeekCnShort(LocalDate localDate)
      获取星期中文简称,比如星期一为一
      Parameters:
      localDate - LocalDate
      Returns:
      String
    • getDayOfWeekCnShort

      public static String getDayOfWeekCnShort(Instant instant)
      获取星期中文简称,比如星期一为一
      Parameters:
      instant - Instant
      Returns:
      String
    • firstDayOfMonth

      public static LocalDate firstDayOfMonth(LocalDate localDate)
      获取当前月的第一天
      Parameters:
      localDate - LocalDate
      Returns:
      LocalDate
    • firstDayOfMonth

      public static LocalDateTime firstDayOfMonth(LocalDateTime localDateTime)
      获取当前月的第一天
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      LocalDateTime
    • firstDayOfMonth

      public static Date firstDayOfMonth(Date date)
      获取当前月的第一天
      Parameters:
      date - Date
      Returns:
      Date
    • lastDayOfMonth

      public static LocalDate lastDayOfMonth(LocalDate localDate)
      获取当前月的最后一天
      Parameters:
      localDate - LocalDate
      Returns:
      LocalDate
    • lastDayOfMonth

      public static LocalDateTime lastDayOfMonth(LocalDateTime localDateTime)
      获取当前月的最后一天
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      LocalDateTime
    • lastDayOfMonth

      public static Date lastDayOfMonth(Date date)
      获取当前月的最后一天
      Parameters:
      date - Date
      Returns:
      Date
    • beginOfSecond

      public static DateTime beginOfSecond(Date date)
      获取秒级别的开始时间,即忽略毫秒部分
      Parameters:
      date - 日期
      Returns:
      DateTime
    • endOfSecond

      public static DateTime endOfSecond(Date date)
      获取秒级别的结束时间,即毫秒设置为999
      Parameters:
      date - 日期
      Returns:
      DateTime
    • beginOfSecond

      public static Calendar beginOfSecond(Calendar calendar)
      修改秒级别的开始时间,即忽略毫秒部分
      Parameters:
      calendar - 日期 Calendar
      Returns:
      Calendar
    • endOfSecond

      public static Calendar endOfSecond(Calendar calendar)
      修改秒级别的结束时间,即毫秒设置为999
      Parameters:
      calendar - 日期 Calendar
      Returns:
      Calendar
    • beginOfMinute

      public static Calendar beginOfMinute(Calendar calendar)
      获取某分钟的开始时间
      Parameters:
      calendar - 日期 Calendar
      Returns:
      Calendar
    • endOfMinute

      public static Calendar endOfMinute(Calendar calendar)
      获取某分钟的结束时间
      Parameters:
      calendar - 日期 Calendar
      Returns:
      Calendar
    • beginOfMinute

      public static DateTime beginOfMinute(Date date)
      获取某分钟的开始时间
      Parameters:
      date - 日期
      Returns:
      DateTime
    • endOfMinute

      public static DateTime endOfMinute(Date date)
      获取某分钟的结束时间
      Parameters:
      date - 日期
      Returns:
      DateTime
    • beginOfHour

      public static Calendar beginOfHour(Calendar calendar)
      修改某小时的开始时间
      Parameters:
      calendar - 日期 Calendar
      Returns:
      Calendar
    • endOfHour

      public static Calendar endOfHour(Calendar calendar)
      修改某小时的结束时间
      Parameters:
      calendar - 日期 Calendar
      Returns:
      Calendar
    • beginOfDay

      public static DateTime beginOfDay(Date date)
      获取某天的开始时间
      Parameters:
      date - 日期
      Returns:
      DateTime
    • endOfDay

      public static DateTime endOfDay(Date date)
      获取某天的结束时间
      Parameters:
      date - 日期
      Returns:
      DateTime
    • beginOfHour

      public static DateTime beginOfHour(Date date)
      获取某小时的开始时间
      Parameters:
      date - 日期
      Returns:
      DateTime
    • endOfHour

      public static DateTime endOfHour(Date date)
      获取某小时的结束时间
      Parameters:
      date - 日期
      Returns:
      DateTime
    • beginOfDay

      public static Calendar beginOfDay(Calendar calendar)
      修改某天的开始时间
      Parameters:
      calendar - 日期 Calendar
      Returns:
      Calendar
    • endOfDay

      public static Calendar endOfDay(Calendar calendar)
      修改某天的结束时间
      Parameters:
      calendar - 日期 Calendar
      Returns:
      Calendar
    • beginOfWeek

      public static DateTime beginOfWeek(Date date)
      获取某周的开始时间,周一定为一周的开始时间
      Parameters:
      date - 日期
      Returns:
      DateTime
    • endOfWeek

      public static DateTime endOfWeek(Date date)
      获取某周的结束时间
      Parameters:
      date - 日期
      Returns:
      DateTime
    • beginOfWeek

      public static Calendar beginOfWeek(Calendar calendar)
      修改给定日期当前周的开始时间,周一定为一周的开始时间
      Parameters:
      calendar - 日期 Calendar
      Returns:
      Calendar
    • beginOfWeek

      public static Calendar beginOfWeek(Calendar calendar, boolean isMondayAsFirstDay)
      修改给定日期当前周的开始时间
      Parameters:
      calendar - 日期 Calendar
      isMondayAsFirstDay - 是否周一做为一周的第一天(false表示周日做为第一天)
      Returns:
      Calendar
    • endOfWeek

      public static Calendar endOfWeek(Calendar calendar)
      修改某周的结束时间,周日定为一周的结束
      Parameters:
      calendar - 日期 Calendar
      Returns:
      Calendar
    • endOfWeek

      public static Calendar endOfWeek(Calendar calendar, boolean isSundayAsLastDay)
      修改某周的结束时间
      Parameters:
      calendar - 日期 Calendar
      isSundayAsLastDay - 是否周日做为一周的最后一天(false表示周六做为最后一天)
      Returns:
      Calendar
    • beginOfMonth

      public static DateTime beginOfMonth(Date date)
      获取某月的开始时间
      Parameters:
      date - 日期
      Returns:
      DateTime
    • endOfMonth

      public static DateTime endOfMonth(Date date)
      获取某月的结束时间
      Parameters:
      date - 日期
      Returns:
      DateTime
    • beginOfMonth

      public static Calendar beginOfMonth(Calendar calendar)
      修改某月的开始时间
      Parameters:
      calendar - 日期 Calendar
      Returns:
      Calendar
    • endOfMonth

      public static Calendar endOfMonth(Calendar calendar)
      修改某月的结束时间
      Parameters:
      calendar - 日期 Calendar
      Returns:
      Calendar
    • beginOfQuarter

      public static DateTime beginOfQuarter(Date date)
      获取某季度的开始时间
      Parameters:
      date - 日期
      Returns:
      DateTime
    • endOfQuarter

      public static DateTime endOfQuarter(Date date)
      获取某季度的结束时间
      Parameters:
      date - 日期
      Returns:
      DateTime
    • beginOfQuarter

      public static Calendar beginOfQuarter(Calendar calendar)
      修改某季度的开始时间
      Parameters:
      calendar - 日期 Calendar
      Returns:
      Calendar
    • endOfQuarter

      public static Calendar endOfQuarter(Calendar calendar)
      修改某季度的结束时间
      Parameters:
      calendar - 日期 Calendar
      Returns:
      Calendar
    • beginOfYear

      public static DateTime beginOfYear(Date date)
      获取某年的开始时间
      Parameters:
      date - 日期
      Returns:
      DateTime
    • endOfYear

      public static DateTime endOfYear(Date date)
      获取某年的结束时间
      Parameters:
      date - 日期
      Returns:
      DateTime
    • beginOfYear

      public static Calendar beginOfYear(Calendar calendar)
      修改某年的开始时间
      Parameters:
      calendar - 日期 Calendar
      Returns:
      Calendar
    • endOfYear

      public static Calendar endOfYear(Calendar calendar)
      修改某年的结束时间
      Parameters:
      calendar - 日期 Calendar
      Returns:
      Calendar
    • isLeapYear

      public static boolean isLeapYear(LocalDate localDate)
      判断是否闰年
      Parameters:
      localDate - LocalDate
      Returns:
      boolean
    • isLeapYear

      public static boolean isLeapYear(LocalDateTime localDateTime)
      判断是否闰年
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      boolean
    • isLeapYear

      public static boolean isLeapYear(Date date)
      判断是否闰年
      Parameters:
      date - Date
      Returns:
      boolean
    • isLeapYear

      public static boolean isLeapYear(int year)
      判断是否闰年
      Parameters:
      year - 年
      Returns:
      boolean
    • nextLeapYear

      public static int nextLeapYear(int year)
      下一个闰年
      Parameters:
      year - 年
      Returns:
      int
    • nextLeapYear

      public static LocalDateTime nextLeapYear(LocalDateTime localDateTime)
      下一个闰年
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      LocalDateTime
    • nextLeapYear

      public static LocalDate nextLeapYear(LocalDate localDate)
      下一个闰年
      Parameters:
      localDate - LocalDate
      Returns:
      LocalDate
    • nextLeapYear

      public static Date nextLeapYear(Date date)
      下一个闰年
      Parameters:
      date - Date
      Returns:
      Date
    • isWorkDay

      public static boolean isWorkDay(Date date)
      判断是否工作日 (周一到周五)
      Parameters:
      date - Date
      Returns:
      boolean
    • isWorkDay

      public static boolean isWorkDay(LocalDateTime localDateTime)
      判断是否工作日 (周一到周五)
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      boolean
    • isWorkDay

      public static boolean isWorkDay(LocalDate localDate)
      判断是否工作日 (周一到周五)
      Parameters:
      localDate - LocalDate
      Returns:
      boolean
    • isWeekend

      public static boolean isWeekend(Date date)
      判断是否周末(周六周日)
      Parameters:
      date - Date
      Returns:
      boolean
    • isWeekend

      public static boolean isWeekend(LocalDateTime localDateTime)
      判断是否周末(周六周日)
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      boolean
    • isWeekend

      public static boolean isWeekend(LocalDate localDate)
      判断是否周末(周六周日)
      Parameters:
      localDate - LocalDate
      Returns:
      boolean
    • lengthOfMonth

      public static int lengthOfMonth(LocalDate localDate)
      获取月的天数
      Parameters:
      localDate - LocalDate
      Returns:
      int
    • lengthOfMonth

      public static int lengthOfMonth(LocalDateTime localDateTime)
      获取月的天数
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      int
    • lengthOfMonth

      public static int lengthOfMonth(Date date)
      获取月的天数
      Parameters:
      date - Date
      Returns:
      int
    • lengthOfYear

      public static int lengthOfYear(LocalDate localDate)
      获取年的天数
      Parameters:
      localDate - LocalDate
      Returns:
      int
    • lengthOfYear

      public static int lengthOfYear(LocalDateTime localDateTime)
      获取年的天数
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      int
    • lengthOfYear

      public static int lengthOfYear(Date date)
      获取年的天数
      Parameters:
      date - Date
      Returns:
      int
    • next

      public static LocalDate next(LocalDate localDate, DayOfWeek dayOfWeek)
      下一个星期几
      Parameters:
      localDate - 日期
      dayOfWeek - 星期
      Returns:
      LocalDate
    • next

      public static LocalDateTime next(LocalDateTime localDateTime, DayOfWeek dayOfWeek)
      下一个星期几
      Parameters:
      localDateTime - 日期
      dayOfWeek - 星期
      Returns:
      LocalDateTime
    • next

      public static Date next(Date date, DayOfWeek dayOfWeek)
      下一个星期几
      Parameters:
      date - 日期
      dayOfWeek - 星期
      Returns:
      Date
    • previous

      public static LocalDate previous(LocalDate localDate, DayOfWeek dayOfWeek)
      上一个星期几
      Parameters:
      localDate - 日期
      dayOfWeek - 星期
      Returns:
      LocalDate
    • previous

      public static LocalDateTime previous(LocalDateTime localDateTime, DayOfWeek dayOfWeek)
      上一个星期几
      Parameters:
      localDateTime - 日期
      dayOfWeek - 星期
      Returns:
      LocalDateTime
    • previous

      public static Date previous(Date date, DayOfWeek dayOfWeek)
      上一个星期几
      Parameters:
      date - 日期
      dayOfWeek - 星期
      Returns:
      Date
    • nextWorkDay

      public static LocalDate nextWorkDay(LocalDate localDate)
      获下一个工作日
      Parameters:
      localDate - LocalDate
      Returns:
      LocalDate
    • nextWorkDay

      public static LocalDateTime nextWorkDay(LocalDateTime localDateTime)
      获下一个工作日
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      LocalDateTime
    • nextWorkDay

      public static Date nextWorkDay(Date date)
      获下一个工作日
      Parameters:
      date - Date
      Returns:
      Date
    • nextWorkDay

      public static TemporalAdjuster nextWorkDay()
      下一个工作日
      Returns:
      TemporalAdjuster
    • getZonedDateTimeNowOfDefault

      public static ZonedDateTime getZonedDateTimeNowOfDefault()
      获取当前系统当前时区时间
      Returns:
      ZonedDateTime
    • getZonedDateTimeNowOfCTT

      public static ZonedDateTime getZonedDateTimeNowOfCTT()
      获取当前上海时区时间(北京时间)
      Returns:
      ZonedDateTime
    • getZonedDateTimeNowOfECT

      public static ZonedDateTime getZonedDateTimeNowOfECT()
      获取当前巴黎时区时间
      Returns:
      ZonedDateTime
    • getZonedDateTimeNowOfEST

      public static ZonedDateTime getZonedDateTimeNowOfEST()
      获取当前美国东部标准时区
      Returns:
      ZonedDateTime
    • getZonedDateTimeNowOfJST

      public static ZonedDateTime getZonedDateTimeNowOfJST()
      获取当前东京时区时间
      Returns:
      ZonedDateTime
    • with

      public static Temporal with(Temporal temporal, TemporalField field, long newValue)
      根据field修改属性
      Parameters:
      temporal - Temporal
      field - 属性
      newValue - 新值
      Returns:
      Temporal
    • with

      public static Date with(Date date, TemporalField field, long newValue)
      根据field修改属性
      Parameters:
      date - 日期
      field - 属性
      newValue - 新值
      Returns:
      Date
    • durationBetween

      public static Duration durationBetween(Temporal startInclusive, Temporal endExclusive)
      获取2个日期的总的天时分秒毫秒纳秒
      Parameters:
      startInclusive - 开始时间
      endExclusive - 结束时间
      Returns:
      Duration
    • periodBetween

      public static Period periodBetween(LocalDate startDateInclusive, LocalDate endDateExclusive)
      获取2个日期的相差年月日部分属性
      Parameters:
      startDateInclusive - 开始时间
      endDateExclusive - 结束时间
      Returns:
      Period
    • getZonedDateTimeNow

      public static ZonedDateTime getZonedDateTimeNow(String zoneId)
      获取时区当前时间
      Parameters:
      zoneId - 时区
      Returns:
      ZonedDateTime
    • transform

      public static ZonedDateTime transform(ZonedDateTime zonedDateTime, String zoneId)
      时区转换计算
      Parameters:
      zonedDateTime - ZonedDateTime
      zoneId - 例如 Asia/Shanghai
      Returns:
      ZonedDateTime
    • transform

      public static ZonedDateTime transform(ZonedDateTime zonedDateTime, ZoneId zone)
      时区转换计算
      Parameters:
      zonedDateTime - ZonedDateTime
      zone - 时区
      Returns:
      ZonedDateTime
    • transform

      public static String transform(Date date, String zoneId)
      时区转换计算
      Parameters:
      date - Date
      zoneId - 目标时区
      Returns:
      日期 yyyy-MM-dd HH:mm:ss
    • transform

      public static String transform(Date date, ZoneId zone)
      时区转换计算
      Parameters:
      date - Date
      zone - 目标时区
      Returns:
      日期 yyyy-MM-dd HH:mm:ss
    • compare

      public static int compare(Date date1, Date date2)
      比较2个时间Date
      Parameters:
      date1 - 时间1
      date2 - 时间2
      Returns:
      int date1 大于 date2 返回1, date1 小于 date2 返回-1,date1 等于date2 返回0
    • compare

      public static int compare(Temporal temporal1, Temporal temporal2)
      比较2个时间,可用于LocalDateTime,LocalDate,LocalTime,Instant
      Parameters:
      temporal1 - 时间1
      temporal2 - 时间2
      Returns:
      int temporal1 大于 temporal2 返回1, temporal1 小于 temporal2 返回-1,temporal1 等于temporal2 返回0
    • compare

      public static int compare(Date date)
      两个时间比较
      Parameters:
      date - 日期
      Returns:
      时间差
    • compare

      public static int compare(long date)
      两个时间比较(时间戳比较)
      Parameters:
      date - 日期
      Returns:
      时间差
    • compare

      public static boolean compare(String object)
      两个时间比较(时间戳比较)
      Parameters:
      object - 字符串日期
      Returns:
      the boolean
    • startTimeOfDay

      public static LocalTime startTimeOfDay()
      一天开始时间 00:00:00
      Returns:
      LocalTime
    • endTimeOfDay

      public static LocalTime endTimeOfDay()
      一天开始时间 23:59:59
      Returns:
      LocalTime
    • endAccuracyTimeOfDay

      public static LocalTime endAccuracyTimeOfDay()
      一天结束时间 精确时间到纳秒 23:59:59.999999999
      Returns:
      LocalTime
    • startTimeOfYesterday

      public static Date startTimeOfYesterday()
      昨天起始时间 即:昨天日期+00:00:00
      Returns:
      Date
    • endTimeOfYesterday

      public static Date endTimeOfYesterday()
      昨天结束时间即:昨天日期+23:59:59
      Returns:
      Date
    • startTimeOfTomorrow

      public static Date startTimeOfTomorrow()
      明天起始时间 即:明天日期+00:00:00
      Returns:
      Date
    • endTimeOfTomorrow

      public static Date endTimeOfTomorrow()
      明天结束时间即:明天日期+23:59:59
      Returns:
      Date
    • startTimeOfToday

      public static Date startTimeOfToday()
      今天起始时间 即:今天日期+00:00:00
      Returns:
      Date
    • endTimeOfToday

      public static Date endTimeOfToday()
      今天结束时间即:今天日期+23:59:59
      Returns:
      Date
    • startTimeOfLastMonth

      public static Date startTimeOfLastMonth()
      上个月第一天起始时间 即:上个月第一天日期+00:00:00
      Returns:
      Date
    • endTimeOfLastMonth

      public static Date endTimeOfLastMonth()
      上个月最后一天结束时间 即:上个月最后一天日期+23:59:59
      Returns:
      Date
    • startTimeOfMonth

      public static Date startTimeOfMonth()
      当月第一天起始时间 即:当月第一天日期+00:00:00
      Returns:
      Date
    • endTimeOfMonth

      public static Date endTimeOfMonth()
      当月最后一天结束时间即:当月最后一天日期+23:59:59
      Returns:
      Date
    • startTimeOfDate

      public static Date startTimeOfDate(Date date)
      获date起始时间
      Parameters:
      date - Date
      Returns:
      Date
    • endTimeOfDate

      public static Date endTimeOfDate(Date date)
      获取date结束时间 精确到秒 23:59:59
      Parameters:
      date - Date
      Returns:
      Date
    • endAccuracyTimeOfDate

      public static Date endAccuracyTimeOfDate(Date date)
      获localDateTime结束时间,精确时间到纳秒 23:59:59.999000000 (转换为Date会丢失毫秒以后数据)
      Parameters:
      date - Date
      Returns:
      Date
    • startTimeOfLocalDateTime

      public static LocalDateTime startTimeOfLocalDateTime(LocalDateTime localDateTime)
      获localDateTime起始时间
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      LocalDateTime
    • endAccuracyTimeOfLocalDateTime

      public static LocalDateTime endAccuracyTimeOfLocalDateTime(LocalDateTime localDateTime)
      获取localDateTime结束时间,精确时间到纳秒 23:59:59.999999999
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      LocalDateTime
    • startTimeOfSpecialMonth

      public static Date startTimeOfSpecialMonth(int year, int month)
      获取指定年月的第一天起始时间
      Parameters:
      year - 年
      month - 月
      Returns:
      Date
    • endTimeOfSpecialMonth

      public static Date endTimeOfSpecialMonth(int year, int month)
      获取指定年月的最后一天结束时间
      Parameters:
      year - 年
      month - 月
      Returns:
      Date
    • startTimeOfDate

      public static Date startTimeOfDate(int year, int month, int dayOfMonth)
      获取指定日期的起始时间
      Parameters:
      year - 年
      month - 月
      dayOfMonth - 日
      Returns:
      Date
    • endTimeOfDate

      public static Date endTimeOfDate(int year, int month, int dayOfMonth)
      获取指定日期的结束时间
      Parameters:
      year - 年
      month - 月
      dayOfMonth - 日
      Returns:
      Date
    • startTimeOfFirstQuarter

      public static Date startTimeOfFirstQuarter(int year)
      获取第一季度起始日期的开始时间
      Parameters:
      year - 年
      Returns:
      Date
    • startTimeOfSecondQuarter

      public static Date startTimeOfSecondQuarter(int year)
      获取第二季度起始日期的开始时间
      Parameters:
      year - 年
      Returns:
      Date
    • startTimeOfThirdQuarter

      public static Date startTimeOfThirdQuarter(int year)
      获取第三季度起始日期的开始时间
      Parameters:
      year - 年
      Returns:
      Date
    • startTimeOfFourthQuarter

      public static Date startTimeOfFourthQuarter(int year)
      获取第四季度起始日期的开始时间
      Parameters:
      year - 年
      Returns:
      Date
    • endTimeOfFirstQuarter

      public static Date endTimeOfFirstQuarter(int year)
      获取第一季度结束日期的开始时间
      Parameters:
      year - 年
      Returns:
      Date
    • endTimeOfSecondQuarter

      public static Date endTimeOfSecondQuarter(int year)
      获取第二季度结束日期的开始时间
      Parameters:
      year - 年
      Returns:
      Date
    • endTimeOfThirdQuarter

      public static Date endTimeOfThirdQuarter(int year)
      获取第三季度结束日期的开始时间
      Parameters:
      year - 年
      Returns:
      Date
    • endTimeOfFourthQuarter

      public static Date endTimeOfFourthQuarter(int year)
      获取第四季度结束日期的开始时间
      Parameters:
      year - 年
      Returns:
      Date
    • startTimeOfCurrentQuarter

      public static Date startTimeOfCurrentQuarter()
      获取当前季度起始日期的开始时间
      Returns:
      Date
    • endTimeOfCurrentQuarter

      public static Date endTimeOfCurrentQuarter()
      获取当前季度结束日期的时间
      Returns:
      Date
    • startTimeOfYear

      public static Date startTimeOfYear(int year)
      获取指定年起始日期的开始时间
      Parameters:
      year - 年
      Returns:
      Date
    • endTimeOfYear

      public static Date endTimeOfYear(int year)
      获取指定年结束日期的开始时间
      Parameters:
      year - 年
      Returns:
      Date
    • startTimeOfCurrentYear

      public static Date startTimeOfCurrentYear()
      获取当前年起始日期的开始时间
      Returns:
      Date
    • endTimeOfCurrentYear

      public static Date endTimeOfCurrentYear()
      获取当前年结束日期的时间
      Returns:
      Date
    • isSameTime

      public static boolean isSameTime(Calendar date1, Calendar date2)
      检查两个Calendar时间戳是否相同 此方法检查两个Calendar的毫秒数时间戳是否相同
      Parameters:
      date1 - 时间1
      date2 - 时间2
      Returns:
      两个Calendar时间戳是否相同。如果两个时间都为 null返回true,否则有null返回false
    • isSameTime

      public static boolean isSameTime(Date date1, Date date2)
      是否为相同时间 此方法比较两个日期的时间戳是否相同
      Parameters:
      date1 - 日期1
      date2 - 日期2
      Returns:
      是否为相同时间
    • isSameDay

      public static boolean isSameDay(Calendar cal1, Calendar cal2)
      比较两个日期是否为同一天
      Parameters:
      cal1 - 日期1
      cal2 - 日期2
      Returns:
      是否为同一天
    • isSameDay

      public static boolean isSameDay(Date date1, Date date2)
      比较两个日期是否为同一天
      Parameters:
      date1 - 日期1
      date2 - 日期2
      Returns:
      是否为同一天
    • isSameDay

      public static boolean isSameDay(LocalDate date1, LocalDate date2)
      比较两个日期是否为同一天
      Parameters:
      date1 - 日期1
      date2 - 日期2
      Returns:
      是否为同一天
    • isSameDay

      public static boolean isSameDay(LocalDateTime date1, LocalDateTime date2)
      比较两个日期是否为同一天
      Parameters:
      date1 - 日期1
      date2 - 日期2
      Returns:
      是否为同一天
    • isSameWeek

      public static boolean isSameWeek(Calendar cal1, Calendar cal2, boolean isMon)
      比较两个日期是否为同一周
      Parameters:
      cal1 - 日期1
      cal2 - 日期2
      isMon - 是否为周一。国内第一天为星期一,国外第一天为星期日
      Returns:
      是否为同一周
    • isSameWeek

      public static boolean isSameWeek(Date date1, Date date2, boolean isMon)
      比较两个日期是否为同一周
      Parameters:
      date1 - 日期1
      date2 - 日期2
      isMon - 是否为周一。国内第一天为星期一,国外第一天为星期日
      Returns:
      是否为同一周
    • isSameMonth

      public static boolean isSameMonth(Date date1, Date date2)
      比较两个日期是否为同一月
      Parameters:
      date1 - 日期1
      date2 - 日期2
      Returns:
      是否为同一月
    • isSameMonth

      public static boolean isSameMonth(Calendar cal1, Calendar cal2)
      比较两个日期是否为同一月
      Parameters:
      cal1 - 日期1
      cal2 - 日期2
      Returns:
      是否为同一月
    • isSameMonthDay

      public static boolean isSameMonthDay(LocalDate localDate1, MonthDay monthDay)
      相同月日比较判断,用于生日,节日等周期性的日期比较判断
      Parameters:
      localDate1 - 日期1
      monthDay - 月日
      Returns:
      boolean
    • isSameMonthDay

      public static boolean isSameMonthDay(LocalDate localDate1, String monthDayStr)
      相同月日比较判断,用于生日,节日等周期性的日期比较判断
      Parameters:
      localDate1 - 日期1
      monthDayStr - 月日字符串 MM-dd格式
      Returns:
      boolean
    • isSameMonthDay

      public static boolean isSameMonthDay(LocalDate localDate1, LocalDate localDate2)
      相同月日比较判断,用于生日,节日等周期性的日期比较判断。
      Parameters:
      localDate1 - 日期1
      localDate2 - 日期2
      Returns:
      boolean
    • isSameMonthDay

      public static boolean isSameMonthDay(Date date, String monthDayStr)
      相同月日比较判断,用于生日,节日等周期性的日期比较判断。
      Parameters:
      date - 日期
      monthDayStr - 月日字符串,MM-dd格式
      Returns:
      boolean
    • isSameMonthDay

      public static boolean isSameMonthDay(Date date1, Date date2)
      相同月日比较判断,用于生日,节日等周期性的日期比较判断。
      Parameters:
      date1 - 日期1
      date2 - 日期2
      Returns:
      boolean
    • isSameMonthDayOfNow

      public static boolean isSameMonthDayOfNow(String monthDayStr)
      相同月日比较判断,与当前日期对比,用于生日,节日等周期性的日期比较判断
      Parameters:
      monthDayStr - 月日字符串,MM-dd格式
      Returns:
      boolean
    • betweenNextSameMonthDay

      public static long betweenNextSameMonthDay(LocalDate localDate1, int month, int dayOfMonth)
      下个固定月日相差天数,用于生日,节日等周期性的日期推算
      Parameters:
      localDate1 - 日期1
      month - 月
      dayOfMonth - 日
      Returns:
      long
    • betweenNextSameMonthDay

      public static long betweenNextSameMonthDay(LocalDate localDate, String monthDayStr)
      下个固定月日相差天数,用于生日,节日等周期性的日期推算
      Parameters:
      localDate - 日期
      monthDayStr - 月日字符串,MM-dd格式
      Returns:
      long
    • betweenNextSameMonthDay

      public static long betweenNextSameMonthDay(Date date, String monthDayStr)
      下个固定月日相差天数,用于生日,节日等周期性的日期推算
      Parameters:
      date - 日期
      monthDayStr - 月日字符串,MM-dd格式
      Returns:
      long
    • betweenNextSameMonthDayOfNow

      public static long betweenNextSameMonthDayOfNow(String monthDayStr)
      下个固定月日相差天数,与当前日期对比,用于生日,节日等周期性的日期推算
      Parameters:
      monthDayStr - 月日字符串,MM-dd格式
      Returns:
      long
    • nextSameMonthDay

      public static LocalDate nextSameMonthDay(LocalDate localDate, String monthDayStr)
      下个固定月日相差日期,用于生日,节日等周期性的日期推算
      Parameters:
      localDate - 日期
      monthDayStr - 月日字符串,MM-dd格式
      Returns:
      LocalDate
    • nextSameMonthDay

      public static Date nextSameMonthDay(Date date, String monthDayStr)
      下个固定月日相差日期,用于生日,节日等周期性的日期推算
      Parameters:
      date - 日期
      monthDayStr - 月日字符串,MM-dd格式
      Returns:
      Date
    • nextSameMonthDayOfNow

      public static Date nextSameMonthDayOfNow(String monthDayStr)
      下个固定月日相差日期,与当前日期对比,用于生日,节日等周期性的日期推算
      Parameters:
      monthDayStr - 月日字符串,MM-dd格式
      Returns:
      Date
    • getZodiacCnName

      public static String getZodiacCnName(String monthDay)
      根据日期查询星座中文名称
      Parameters:
      monthDay - 月日字符串,MM-dd格式
      Returns:
      String
    • getZodiacCnName

      public static String getZodiacCnName(Date date)
      根据日期查询星座中文名称
      Parameters:
      date - Date
      Returns:
      String
    • getZodiacEnName

      public static String getZodiacEnName(String monthDay)
      根据日期查询星座英文名称
      Parameters:
      monthDay - 月日字符串,MM-dd格式
      Returns:
      String
    • getZodiacEnName

      public static String getZodiacEnName(Date date)
      根据日期查询星座中文名称
      Parameters:
      date - Date
      Returns:
      String
    • getZodiac

      public static String getZodiac(Date date)
      通过生日计算星座
      Parameters:
      date - 出生日期
      Returns:
      星座名
    • getZodiac

      public static String getZodiac(Calendar calendar)
      通过生日计算星座
      Parameters:
      calendar - 出生日期
      Returns:
      星座名
    • getZodiac

      public static String getZodiac(int month, int day)
      通过生日计算星座
      Parameters:
      month - 月,从0开始计数
      day - 天
      Returns:
      星座名
    • getLocalDateTimeList

      public static List<LocalDateTime> getLocalDateTimeList(LocalDateTime startInclusive, LocalDateTime endInclusive)
      获取指定区间的时间列表,包含起始
      Parameters:
      startInclusive - 开始时间
      endInclusive - 结束时间
      Returns:
      时间列表
    • getLocalDateList

      public static List<LocalDate> getLocalDateList(LocalDate startInclusive, LocalDate endInclusive)
      获取指定区间的时间列表,包含起始
      Parameters:
      startInclusive - 开始时间
      endInclusive - 结束时间
      Returns:
      时间列表
    • getLocalDateList

      public static List<LocalDate> getLocalDateList(YearMonth yearMonth)
      获取指定年月的所有日期列表
      Parameters:
      yearMonth - 年月
      Returns:
      时间列表
    • getLocalDateList

      public static List<LocalDate> getLocalDateList(String yearMonthStr)
      获取指定年月的所有日期列表
      Parameters:
      yearMonthStr - 年月字符串,格式: yyyy-MM
      Returns:
      时间列表
    • getLocalDateList

      public static List<LocalDate> getLocalDateList(int year, int month)
      获取指定年月的所有日期列表
      Parameters:
      year - 年
      month - 月
      Returns:
      时间列表
    • getLocalDateTimeList

      public static List<LocalDateTime> getLocalDateTimeList(YearMonth yearMonth)
      获取指定年月的所有日期列表
      Parameters:
      yearMonth - 年月
      Returns:
      时间列表
    • getLocalDateTimeList

      public static List<LocalDateTime> getLocalDateTimeList(String yearMonthStr)
      获取指定年月的所有日期列表
      Parameters:
      yearMonthStr - 年月字符串,格式: yyyy-MM
      Returns:
      时间列表
    • getLocalDateTimeList

      public static List<LocalDateTime> getLocalDateTimeList(int year, int month)
      获取指定年月的所有日期列表
      Parameters:
      year - 年
      month - 月
      Returns:
      时间列表
    • getDateList

      public static List<Date> getDateList(String yearMonthStr)
      获取指定年月的所有日期列表
      Parameters:
      yearMonthStr - 年月字符串,格式: yyyy-MM
      Returns:
      时间列表
    • getDateList

      public static List<Date> getDateList(int year, int month)
      获取指定年月的所有日期列表
      Parameters:
      year - 年
      month - 月
      Returns:
      时间列表
    • getDateList

      public static List<Date> getDateList(Date startInclusive, Date endInclusive)
      获取指定区间的时间列表,包含起始
      Parameters:
      startInclusive - 开始时间
      endInclusive - 结束时间
      Returns:
      时间列表
    • isExpiry

      public static boolean isExpiry(YearMonth yearMonth)
      判断是否过期,(输入年月小于当前年月)
      Parameters:
      yearMonth - 年月
      Returns:
      boolean
    • isExpiry

      public static boolean isExpiry(String value)
      判断是否过期,(输入年月小于当前年月)
      Parameters:
      value - 年月字符串,格式: yyyy-MM
      Returns:
      boolean
    • isBirthday

      public static boolean isBirthday(CharSequence value)
      验证是否为生日 只支持以下几种格式:
      • yyyyMMdd
      • yyyy-MM-dd
      • yyyy/MM/dd
      • yyyy.MM.dd
      • yyyy年MM月dd日
      Parameters:
      value - 值
      Returns:
      是否为生日
    • isBirthDay

      public static boolean isBirthDay(Date date)
      是否为生日
      Parameters:
      date - 生日
      Returns:
      boolean
    • isBirthDay

      public static boolean isBirthDay(LocalDate localDate)
      是否为生日
      Parameters:
      localDate - 生日
      Returns:
      boolean
    • isBirthDay

      public static boolean isBirthDay(LocalDateTime localDateTime)
      是否为生日
      Parameters:
      localDateTime - 生日
      Returns:
      boolean
    • isBirthday

      public static boolean isBirthday(int year, int month, int day)
      验证是否为生日
      Parameters:
      year - 年,从1900年开始计算
      month - 月,从1开始计数
      day - 日,从1开始计数
      Returns:
      是否为生日
    • reduceAccuracyToSecond

      public static LocalDateTime reduceAccuracyToSecond(LocalDateTime localDateTime)
      减少时间精度到秒,其他补0,返回如,2020-04-23 15:18:13
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      LocalDateTime
    • reduceAccuracyToSecond

      public static Date reduceAccuracyToSecond(Date date)
      减少时间精度到秒,其他补0,返回如,2020-04-23 15:18:13
      Parameters:
      date - Date
      Returns:
      Date
    • reduceAccuracyToMinute

      public static LocalDateTime reduceAccuracyToMinute(LocalDateTime localDateTime)
      减少时间精度到分,其他补0,返回如,2020-04-23 15:18:00
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      LocalDateTime
    • reduceAccuracyToMinute

      public static Date reduceAccuracyToMinute(Date date)
      减少时间精度到分,其他补0,返回如,2020-04-23 15:18:00
      Parameters:
      date - Date
      Returns:
      Date
    • reduceAccuracyToHour

      public static LocalDateTime reduceAccuracyToHour(LocalDateTime localDateTime)
      减少时间精度到小时,其他补0,返回如,2020-04-23 15:00:00
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      LocalDateTime
    • reduceAccuracyToHour

      public static Date reduceAccuracyToHour(Date date)
      减少时间精度到小时,其他补0,返回如,2020-04-23 15:00:00
      Parameters:
      date - Date
      Returns:
      Date
    • reduceAccuracyToDay

      public static LocalDateTime reduceAccuracyToDay(LocalDateTime localDateTime)
      减少时间精度到天,其他补0,返回如,2020-04-23 00:00:00
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      LocalDateTime
    • reduceAccuracyToDay

      public static Date reduceAccuracyToDay(Date date)
      减少时间精度到天,其他补0,返回如,2020-04-23 00:00:00
      Parameters:
      date - Date
      Returns:
      Date
    • weekOfMonth

      public static int weekOfMonth(LocalDate localDate, Locale locale)
      日期所在月中第几周
      Parameters:
      localDate - LocalDate
      locale - 地区 为null 是取系统默认地区
      Returns:
      周数
    • weekOfMonth

      public static int weekOfMonth(LocalDate localDate)
      日期所在月中第几周
      Parameters:
      localDate - LocalDate
      Returns:
      周数
    • weekOfMonth

      public static int weekOfMonth(LocalDateTime localDateTime)
      日期所在月中第几周
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      周数
    • weekOfMonth

      public static int weekOfMonth(Date date)
      日期所在月中第几周
      Parameters:
      date - Date
      Returns:
      周数
    • weekOfMonth

      public static int weekOfMonth()
      当前日期所在月中第几周
      Returns:
      周数
    • weekOfYear

      public static int weekOfYear(LocalDate localDate, Locale locale)
      日期所在年中第几周
      Parameters:
      localDate - LocalDate
      locale - 地区 为null 是取系统默认地区
      Returns:
      周数
    • weekOfYear

      public static int weekOfYear(LocalDate localDate)
      日期所在年中第几周
      Parameters:
      localDate - LocalDate
      Returns:
      周数
    • weekOfYear

      public static int weekOfYear(LocalDateTime localDateTime)
      日期所在年中第几周
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      周数
    • weekOfYear

      public static int weekOfYear(Date date)
      日期所在年中第几周
      Parameters:
      date - Date
      Returns:
      周数
    • weekOfYear

      public static int weekOfYear()
      当前日期所在年中第几周
      Returns:
      周数
    • isMonday

      public static boolean isMonday(LocalDate localDate)
      是否为周一
      Parameters:
      localDate - LocalDate
      Returns:
      是 true 否 false
    • isMonday

      public static boolean isMonday(Date date)
      是否为周一
      Parameters:
      date - Date
      Returns:
      是 true 否 false
    • isFriday

      public static boolean isFriday(LocalDate localDate)
      是否为周五
      Parameters:
      localDate - LocalDate
      Returns:
      是 true 否 false
    • isFriday

      public static boolean isFriday(Date date)
      是否为周五
      Parameters:
      date - Date
      Returns:
      是 true 否 false
    • isDate

      public static boolean isDate(String dptDate, String pattern)
      校验日期格式,日期不能早于当前天
      Parameters:
      dptDate - 日期, 仅需包含年月日
      pattern - 日期转移格式
      Returns:
      true/false
    • isDate

      public static boolean isDate(String dptDate)
      校验日期格式,日期不能早于当前天, 默认日期转义格式:yyyy-MM-dd
      Parameters:
      dptDate - 日期,仅需包含年月日
      Returns:
      true/false
    • isBefore

      public static boolean isBefore(String go, String back, String pattern)
      校验前面的日期go,是否早于或者等于后面的日期back
      Parameters:
      go - 日期1
      back - 日期2
      pattern - 日期正则表达式
      Returns:
      true/false
    • isBefore

      public static boolean isBefore(String go, String back)
      校验前面的日期go,是否早于或者等于后面的日期back
      Parameters:
      go - 日期1
      back - 日期2
      Returns:
      true/false
    • isDatetime

      public static boolean isDatetime(String datetime)
      验证长日期格式yyyy-MM-dd HH:mm:ss
      Parameters:
      datetime - 日期
      Returns:
      true/false
    • isShortDate

      public static boolean isShortDate(String date)
      校验短日期格式[yyyyMMdd]
      Parameters:
      date - 短日期
      Returns:
      true/false
    • isOverlap

      public static boolean isOverlap(ChronoLocalDateTime<?> realStartTime, ChronoLocalDateTime<?> realEndTime, ChronoLocalDateTime<?> startTime, ChronoLocalDateTime<?> endTime)
      检查两个时间段是否有时间重叠 重叠指两个时间段是否有交集
      1. x > b || a > y 无交集
      2. 则有交集的逻辑为 !(x > b || a > y) 根据德摩根公式,可化简为 x <= b && a <= y
      Parameters:
      realStartTime - 第一个时间段的开始时间
      realEndTime - 第一个时间段的结束时间
      startTime - 第二个时间段的开始时间
      endTime - 第二个时间段的结束时间
      Returns:
      true 表示时间有重合
    • isNotLessThanToday

      public static boolean isNotLessThanToday(String date)
      判断传入的日期是否 >=今天
      Parameters:
      date - 待判断的日期
      Returns:
      true/false
    • isNotLessThanToday

      public static boolean isNotLessThanToday(String date, String format)
      判断传入的日期是否>=今天
      Parameters:
      date - 待判断的日期
      format - 格式
      Returns:
      true/false
    • isAM

      public static boolean isAM(Date date)
      是否为上午
      Parameters:
      date - 日期
      Returns:
      是否为上午
    • isAM

      public static boolean isAM(Calendar calendar)
      是否为上午
      Parameters:
      calendar - Calendar
      Returns:
      是否为上午
    • isPM

      public static boolean isPM(Date date)
      是否为下午
      Parameters:
      date - 日期
      Returns:
      是否为下午
    • isPM

      public static boolean isPM(Calendar calendar)
      是否为下午
      Parameters:
      calendar - Calendar
      Returns:
      是否为下午
    • isIn

      public static boolean isIn(Date date, Date beginDate, Date endDate)
      判定在指定检查时间是否过期 当前日期是否在日期指定范围内 起始日期和结束日期可以互换
      Parameters:
      date - 被检查的日期
      beginDate - 起始日期
      endDate - 结束日期
      Returns:
      是否在范围内
    • isIn

      public static boolean isIn(TemporalAccessor date, TemporalAccessor beginDate, TemporalAccessor endDate)
      当前日期是否在日期指定范围内 起始日期和结束日期可以互换
      Parameters:
      date - 被检查的日期
      beginDate - 起始日期(包含)
      endDate - 结束日期(包含)
      Returns:
      是否在范围内
    • getChrono

      public static String getChrono(LocalTime localTime)
      获取指定时间对应的十二时辰
      Parameters:
      localTime - LocalTime
      Returns:
      十二时辰名称
    • getChrono

      public static String getChrono(LocalDateTime localDateTime)
      获取指定时间对应的十二时辰
      Parameters:
      localDateTime - LocalDateTime
      Returns:
      十二时辰名称
    • getChrono

      public static String getChrono(Date date)
      获取指定时间对应的十二时辰
      Parameters:
      date - Date
      Returns:
      十二时辰名称
    • getChrono

      public static String getChrono()
      获取当前时间对应的十二时辰
      Returns:
      十二时辰名称
    • getAnimal

      public static String getAnimal(Date date)
      通过生日计算生肖,只计算1900年后出生的人
      Parameters:
      date - 出生日期(年需农历)
      Returns:
      星座名
    • getAnimal

      public static String getAnimal(Calendar calendar)
      通过生日计算生肖,只计算1900年后出生的人
      Parameters:
      calendar - 出生日期(年需农历)
      Returns:
      星座名
    • getAnimal

      public static String getAnimal(int year)
      获取生肖名称
      Parameters:
      year - 农历年
      Returns:
      生肖名
    • getBeginValue

      public static int getBeginValue(Calendar calendar, int dateField)
      获取指定日期字段的最小值,例如分钟的最小值是0
      Parameters:
      calendar - Calendar
      dateField - Fields.Type
      Returns:
      字段最小值
      See Also:
    • getEndValue

      public static int getEndValue(Calendar calendar, int dateField)
      获取指定日期字段的最大值,例如分钟的最大值是59
      Parameters:
      calendar - Calendar
      dateField - Fields.Type
      Returns:
      字段最大值
      See Also:
    • date

      public static DateTime date()
      转换为DateTime对象
      Returns:
      当前时间
    • date

      public static DateTime date(Date date)
      Date类型时间转为DateTime
      Parameters:
      date - Long类型Date(Unix时间戳)
      Returns:
      时间对象
    • date

      public static DateTime date(long date)
      Long类型时间转为DateTime 同时支持10位秒级别时间戳和13位毫秒级别时间戳
      Parameters:
      date - Long类型Date(Unix时间戳)
      Returns:
      时间对象
    • date

      public static DateTime date(Calendar calendar)
      Calendar类型时间转为DateTime
      Parameters:
      calendar - Calendar
      Returns:
      时间对象
    • date

      public static DateTime date(TemporalAccessor temporalAccessor)
      TemporalAccessor类型时间转为DateTime 始终根据已有TemporalAccessor 产生新的DateTime对象
      Parameters:
      temporalAccessor - TemporalAccessor
      Returns:
      时间对象
    • ceiling

      public static DateTime ceiling(Date date, Fields.Type type)
      修改日期为某个时间字段结束时间
      Parameters:
      date - Date
      type - 时间字段
      Returns:
      DateTime
    • ceiling

      public static Calendar ceiling(Calendar calendar, Fields.Type type)
      修改日期为某个时间字段结束时间
      Parameters:
      calendar - Calendar
      type - 时间字段
      Returns:
      Calendar
    • ceiling

      public static Calendar ceiling(Calendar calendar, int dateField, Fields.Modify modify)
      修改日期
      Parameters:
      calendar - Calendar
      dateField - 日期字段,即保留到哪个日期字段
      modify - 修改类型,包括舍去、四舍五入、进一等
      Returns:
      修改后的Calendar
    • ceiling

      public static Calendar ceiling(Calendar calendar, int field, Fields.Modify modify, boolean truncateMillisecond)
      修改日期,取起始值或者结束值可选是否归零毫秒。 在Fields.Modify.TRUNCATE模式下,毫秒始终要归零, 但是在Fields.Modify.CEILINGFields.Modify.ROUND模式下 有时候由于毫秒部分必须为0(如MySQL数据库中),因此在此加上选项
      Parameters:
      calendar - Calendar
      field - 日期字段,即保留到哪个日期字段
      modify - 修改类型,包括舍去、四舍五入、进一等
      truncateMillisecond - 是否归零毫秒
      Returns:
      修改后的Calendar
    • truncate

      public static DateTime truncate(Date date, Fields.Type type)
      修改日期为某个时间字段起始时间
      Parameters:
      date - Date
      type - 时间字段
      Returns:
      DateTime
    • truncate

      public static Calendar truncate(Calendar calendar, Fields.Type type)
      修改日期为某个时间字段起始时间
      Parameters:
      calendar - Calendar
      type - 时间字段
      Returns:
      Calendar
    • round

      public static DateTime round(Date date, Fields.Type type)
      修改日期为某个时间字段四舍五入时间
      Parameters:
      date - Date
      type - 时间字段
      Returns:
      DateTime
    • round

      public static Calendar round(Calendar calendar, Fields.Type type)
      修改日期为某个时间字段四舍五入时间
      Parameters:
      calendar - Calendar
      type - 时间字段
      Returns:
      Calendar
    • between

      public static long between(Date beginDate, Date endDate, Fields.Units units)
      判断两个日期相差的时长,只保留绝对值
      Parameters:
      beginDate - 起始日期
      endDate - 结束日期
      units - 相差的单位
      Returns:
      日期差
    • between

      public static long between(Date beginDate, Date endDate, Fields.Units units, boolean isAbs)
      判断两个日期相差的时长
      Parameters:
      beginDate - 起始日期
      endDate - 结束日期
      units - 相差的单位
      isAbs - 日期间隔是否只保留绝对值正数
      Returns:
      日期差
    • betweenMs

      public static long betweenMs(Date beginDate, Date endDate)
      判断两个日期相差的毫秒数
      Parameters:
      beginDate - 起始日期
      endDate - 结束日期
      Returns:
      日期差
    • betweenDay

      public static long betweenDay(Date beginDate, Date endDate, boolean isReset)
      判断两个日期相差的天数
       有时候我们计算相差天数的时候需要忽略时分秒
       比如:2016-02-01 23:59:59和2016-02-02 00:00:00相差一秒
       如果isReset为false相差天数为0
       如果isReset为true相差天数将被计算为1
       
      Parameters:
      beginDate - 起始日期
      endDate - 结束日期
      isReset - 是否重置时间为起始时间
      Returns:
      日期差
    • betweenMonth

      public static long betweenMonth(Date beginDate, Date endDate, boolean isReset)
      计算两个日期相差月数 在非重置情况下,如果起始日期的天大于结束日期的天,月数要少算1(不足1个月)
      Parameters:
      beginDate - 起始日期
      endDate - 结束日期
      isReset - 是否重置时间为起始时间(重置天时分秒)
      Returns:
      相差月数
    • betweenYear

      public static long betweenYear(Date beginDate, Date endDate, boolean isReset)
      计算两个日期相差年数 在非重置情况下,如果起始日期的月大于结束日期的月,年数要少算1(不足1年)
      Parameters:
      beginDate - 起始日期
      endDate - 结束日期
      isReset - 是否重置时间为起始时间(重置月天时分秒)
      Returns:
      相差年数
    • offsetMillisecond

      public static DateTime offsetMillisecond(Date date, int offset)
      偏移毫秒数
      Parameters:
      date - 日期
      offset - 偏移毫秒数,正数向未来偏移,负数向历史偏移
      Returns:
      偏移后的日期
    • offsetSecond

      public static DateTime offsetSecond(Date date, int offset)
      偏移秒数
      Parameters:
      date - 日期
      offset - 偏移秒数,正数向未来偏移,负数向历史偏移
      Returns:
      偏移后的日期
    • offsetMinute

      public static DateTime offsetMinute(Date date, int offset)
      偏移分钟
      Parameters:
      date - 日期
      offset - 偏移分钟数,正数向未来偏移,负数向历史偏移
      Returns:
      偏移后的日期
    • offsetHour

      public static DateTime offsetHour(Date date, int offset)
      偏移小时
      Parameters:
      date - 日期
      offset - 偏移小时数,正数向未来偏移,负数向历史偏移
      Returns:
      偏移后的日期
    • offsetDay

      public static DateTime offsetDay(Date date, int offset)
      偏移天
      Parameters:
      date - 日期
      offset - 偏移天数,正数向未来偏移,负数向历史偏移
      Returns:
      偏移后的日期
    • offsetWeek

      public static DateTime offsetWeek(Date date, int offset)
      偏移周
      Parameters:
      date - 日期
      offset - 偏移周数,正数向未来偏移,负数向历史偏移
      Returns:
      偏移后的日期
    • offsetMonth

      public static DateTime offsetMonth(Date date, int offset)
      偏移月
      Parameters:
      date - 日期
      offset - 偏移月数,正数向未来偏移,负数向历史偏移
      Returns:
      偏移后的日期
    • offsetYear

      public static DateTime offsetYear(Date date, int offset)
      偏移月
      Parameters:
      date - 日期
      offset - 偏移月数,正数向未来偏移,负数向历史偏移
      Returns:
      偏移后的日期
    • offset

      public static DateTime offset(Date date, Fields.Type type, int offset)
      获取指定日期偏移指定时间后的时间
      Parameters:
      date - 基准日期
      type - 偏移的粒度大小(小时、天、月等)
      offset - 偏移量,正数为向后偏移,负数为向前偏移
      Returns:
      偏移后的日期
    • now

      public static String now()
      当前时间,格式 yyyy-MM-dd HH:mm:ss
      Returns:
      当前时间的标准形式字符串
    • today

      public static String today()
      当前日期,格式 yyyy-MM-dd
      Returns:
      当前日期的标准形式字符串
    • timestamp

      public static long timestamp()
      当前时间毫秒数
      Returns:
      当前时间毫秒数
    • timestamp

      public static long timestamp(boolean isNano)
      当前时间long
      Parameters:
      isNano - 是否为高精度时间
      Returns:
      时间
    • thisYear

      public static int thisYear()
      当前年份
      Returns:
      今年
    • thisMonth

      public static int thisMonth()
      当前月份
      Returns:
      当前月份
    • thisWeek

      public static int thisWeek()
      当前日期是星期几
      Returns:
      当前日期是星期几
    • tomorrow

      public static Date tomorrow()
      明天日期
      Returns:
      Date
    • nextWeek

      public static Date nextWeek()
      下周日期
      Returns:
      Date
    • nextMonth

      public static Date nextMonth()
      下月日期
      Returns:
      Date
    • nextYear

      public static Date nextYear()
      明年日期
      Returns:
      Date
    • yesterday

      public static Date yesterday()
      昨天日期
      Returns:
      Date
    • lastWeek

      public static Date lastWeek()
      上周日期
      Returns:
      Date
    • lastMonth

      public static Date lastMonth()
      上月日期
      Returns:
      Date
    • lastYear

      public static Date lastYear()
      去年日期
      Returns:
      Date