跳到主要内容

Dates

日期操作工具类,提供了日期类型转换以及运算方法。

Maven 包:com.ouroboros:ouroboros-util

Java 包:com.ouroboros.util

方法返回值类型说明
toLocalDateTime(Date date)LocalDateTime将 Date 转换为 LocalDateTime
toLocalDateTime(Instant instant)LocalDateTime将 Instant 转换为 LocalDateTime
toLocalDateTime(LocalDate date, int hour, int minute, int second)LocalDateTime将 LocalDate 转换为 LocalDateTime
toLocalDateTime(LocalDate date)LocalDateTime将 LocalDate 转换为 LocalDateTime
toLocalDateTime(Number timestamp)LocalDateTime将时间戳转换为 LocalDateTime
toLocalDateTime(CharSequence dateString)LocalDateTime将日期字符串转换为 LocalDateTime
toLocalDateTime(CharSequence dateString, CharSequence... formats)LocalDateTime将指定格式的日期字符串转换为 LocalDateTime
toLocalDate(Date date)LocalDate将 Date 类型转换为 LocalDate
toLocalDate(LocalDateTime date)LocalDate将 LocalDateTime 类型转换为 LocalDate
toLocalDate(Number timestamp)LocalDate将时间戳转换为 LocalDate
toLocalDate(CharSequence dateString)LocalDate将字符串转换为 LocalDate
toLocalDate(CharSequence dateString, CharSequence... formats)LocalDate将指定格式的日期字符串转换为 LocalDate
toLocalTime(Date date)LocalTime将 Date 转换为 LocalTime
toLocalTime(LocalDateTime date)LocalTime将 LocalDateTime 转换为 LocalTime
toLocalTime(Number timestamp)LocalTime将时间戳转换为 LocalTime
toLocalTime(CharSequence dateString)LocalTime将日期字符串转换为 LocalTime
toLocalTime(CharSequence dateString, CharSequence... formats)LocalTime将指定格式的日期字符串转换为 LocalTime
toDate(LocalDateTime date)Date将 LocalDateTime 转换为 Date 对象
toDate(LocalDate date)Date将 LocalDate 转换为 Date 对象
toDate(Number timestamp)Date将时间戳转换为 Date
toDate(CharSequence dateString)Date将日期字符串转换为 Date 对象
toDate(CharSequence dateString, CharSequence... formats)Date将指定格式的日期字符串转换为 Date
toString(LocalDateTime date)String返回 ISO-8601 格式日期时间字符串
toString(LocalDate date)String返回 ISO-8601 格式日期字符串
toString(Date date)String返回 ISO-8601 格式日期字符串
toString(LocalDateTime date, String format)String按照指定格式将日期时间转换为字符串
toString(LocalDate date, String format)String按照指定格式将日期时间转换为字符串
toString(Date date, String format)String按照指定格式将日期时间转换为字符串
addTime(LocalDateTime date, int hours, int minutes, int seconds)LocalDateTime返回增加时间后的新日期时间
addTime(Date date, int hours, int minutes, int seconds)Date返回增加时间后的新日期时间
setTime(LocalDateTime date, int hours, int minutes, int seconds)LocalDateTime返回某日期指定时间的对象
setTime(Date date, int hours, int minutes, int seconds)Date返回某日期指定时间的对象
addDays(Date date, int days)Date返回增加天数后的新日期
getTimestamp()Long返回当前时间戳(13 位,即毫秒级)
getTimestamp(Date date)Long获取时间戳(13 位,即毫秒级)
getTimestamp(LocalDateTime date)Long获取时间戳(13 位,即毫秒级)
getTimestamp(LocalDate date)Long获取时间戳(13 位,即毫秒级)
getUnixTimestamp()Long获取当前 UNIX 时间戳(10 位,即秒级)
getUnixTimestamp(Date date)Long获取 UNIX 时间戳(10 位,即秒级)
getUnixTimestamp(LocalDateTime date)Long获取 UNIX 时间戳(10 位,即秒级)
getUnixTimestamp(LocalDate date)Long获取 UNIX 时间戳(10 位,即秒级)
getYearStartDay(LocalDate date)LocalDate获取指定日期当年第一天的日期
getYearEndDay(LocalDate date)LocalDate获取指定日期当年的最后一天的日期
getYearStart(LocalDateTime date)LocalDateTime获取指定日期当年第一天 0 时的日期时间
getYearEnd(LocalDateTime date)LocalDateTime获取指定日期当年最后一天最后一刻的日期时间
getMonthStartDay(LocalDate date)LocalDate获取指定日期当月第一天的日期
getMonthEndDay(LocalDate date)LocalDate获取指定日期当月最后一天的日期
getMonthStart(LocalDateTime date)LocalDateTime获取指定日期当月第一天 0 时的日期时间
getMonthEnd(LocalDateTime date)LocalDateTime获取指定日期当月最后一天最后一刻的日期时间
getWeekStartDay(LocalDate date)LocalDate获取指定日期当周周一的日期
getWeekEndDay(LocalDate date)LocalDate获取指定日期当周周日的日期
getWeekStart(LocalDateTime date)LocalDateTime获取指定日期当周周一的日期时间
getWeekEnd(LocalDateTime date)LocalDateTime获取指定日期当周周日的日期时间
getDayStart(LocalDateTime date)LocalDateTime获取指定日期的开始时间
getDayEnd(LocalDateTime date)LocalDateTime获取指定日期的结束时间
getThisYearStart()LocalDateTime获取今年第一天开始时间
getThisYearEnd()LocalDateTime获取今年最后一天最后一刻
getThisMonthStart()LocalDateTime获取当前月第一天的开始日期时间
getThisMonthEnd()LocalDateTime获取当前月最后一天最后一刻
getTodayStart()LocalDateTime获取今天最开始的日期时间
getTodayEnd()LocalDateTime获取今天最后一刻
getLastYearStart()LocalDateTime获取去年第一天开始时间
getLastYearEnd()LocalDateTime获取去年最后一天的最后一刻
getLastMonthStart(LocalDate date)LocalDateTime获取指定日期上个月的第一天的开始时间
getLastMonthStart(LocalDateTime date)LocalDateTime获取指定日期上个月的第一天的开始时间
getLastMonthEnd(LocalDate date)LocalDateTime获取指定日期上个月的最后一天的最后一刻
getLastMonthEnd(LocalDateTime date)LocalDateTime获取指定日期上个月的最后一天的最后一刻
getThisWeekday(LocalDate date, Integer weekday)LocalDate获取指定日期当周指定天
getThisWeekday(LocalDateTime date, Integer weekday)LocalDate获取指定日期当周指定星期几
getNextWeekday(LocalDate date, Integer weekday)LocalDate获取指定日期的下一个星期几(当周或下周)
getPrevWeekday(LocalDate date, Integer weekday)LocalDate获取指定日期上个星期几(当周或上周)
getNextWeekday(Integer weekday)LocalDate获取下一个周几(本周或下周)
getPrevWeekday(Integer weekday)LocalDate获取上一个周几(本周或上周)
today()LocalDate获取当前日期
now()LocalDateTime获取当前日期时间
getCurrentDate()Date获取当前日期时间

方法

toLocalDateTime(Date date)

方法签名

public static LocalDateTime toLocalDateTime(Date date)

参数说明

参数名类型说明
dateDate需要转换的 Date 对象

返回值

返回一个 LocalDateTime 实例。

toLocalDateTime(Instant instant)

方法签名

public static LocalDateTime toLocalDateTime(Instant instant)

参数说明

参数名类型说明
instantInstant需要转换的 Instant 对象

返回值

返回一个 LocalDateTime 实例。

toLocalDateTime(LocalDate date, int hour, int minute, int second)

方法签名

public static LocalDateTime toLocalDateTime(LocalDate date, int hour, int minute, int second)

参数说明

参数名类型说明
dateLocalDate需要转换的 LocalDate 对象
hourint
minuteint
secondint

返回值

返回一个 LocalDateTime 实例。

toLocalDateTime(LocalDate date)

方法签名

public static LocalDateTime toLocalDateTime(LocalDate date)

参数说明

参数名类型说明
dateLocalDate需要转换的 LocalDate 对象

返回值

返回一个 LocalDateTime 实例。

toLocalDateTime(Number timestamp)

方法签名

public static LocalDateTime toLocalDateTime(Number timestamp)

参数说明

参数名类型说明
timestampNumber需要转换的时间戳

返回值

返回一个 LocalDateTime 实例。

toLocalDateTime(CharSequence dateString)

方法签名

public static LocalDateTime toLocalDateTime(CharSequence dateString)

参数说明

参数名类型说明
dateStringCharSequence需要转换的日期字符串

返回值

若解析失败则返回 LocalDateTime.MIN,否则返回一个 LocalDateTime 实例。

toLocalDateTime(CharSequence dateString, CharSequence... formats)

方法签名

public static LocalDateTime toLocalDateTime(CharSequence dateString, CharSequence... formats)

参数说明

参数名类型说明
dateStringCharSequence需要转换的日期字符串
formatsCharSequence...日期字符串的可能格式

返回值

若解析失败则返回 LocalDateTime.MIN,否则返回一个 LocalDateTime 实例。

toLocalDate(Date date)

方法签名

public static LocalDate toLocalDate(Date date)

参数说明

参数名类型说明
dateDate需要转换的 Date 对象

返回值

返回一个 LocalDate 实例。

toLocalDate(LocalDateTime date)

方法签名

public static LocalDate toLocalDate(LocalDateTime date)

参数说明

参数名类型说明
dateLocalDateTime需要转换的 LocalDateTime 对象

返回值

返回一个 LocalDate 实例。

toLocalDate(Number timestamp)

方法签名

public static LocalDate toLocalDate(Number timestamp)

参数说明

参数名类型说明
timestampNumber需要转换的时间戳

返回值

返回一个 LocalDate 实例。

toLocalDate(CharSequence dateString)

方法签名

public static LocalDate toLocalDate(CharSequence dateString)

参数说明

参数名类型说明
dateStringCharSequence需要转换的日期字符串

返回值

若解析失败则返回 LocalDate.MIN,否则返回一个 LocalDate 实例。

toLocalDate(CharSequence dateString, CharSequence... formats)

方法签名

public static LocalDate toLocalDate(CharSequence dateString, CharSequence... formats)

参数说明

参数名类型说明
dateStringCharSequence需要转换的日期字符串
formatsCharSequence...日期字符串的可能格式

返回值

若解析失败则返回 LocalDate.MIN,否则返回一个 LocalDate 实例。

toLocalTime(Date date)

方法签名

public static LocalTime toLocalTime(Date date)

参数说明

参数名类型说明
dateDate需要转换的 Date 对象

返回值

返回一个 LocalTime 实例。

toLocalTime(LocalDateTime date)

方法签名

public static LocalTime toLocalTime(LocalDateTime date)

参数说明

参数名类型说明
dateLocalDateTime需要转换的 LocalDateTime 对象

返回值

返回一个 LocalTime 实例。

toLocalTime(Number timestamp)

方法签名

public static LocalTime toLocalTime(Number timestamp)

参数说明

参数名类型说明
timestampNumber需要转换的时间戳

返回值

返回一个 LocalTime 实例。

toLocalTime(CharSequence dateString)

方法签名

public static LocalTime toLocalTime(CharSequence dateString)

参数说明

参数名类型说明
dateStringCharSequence需要转换的日期字符串

返回值

若解析失败则返回 LocalTime.MIN,否则返回一个 LocalTime 实例。

toLocalTime(CharSequence dateString, CharSequence... formats)

方法签名

public static LocalTime toLocalTime(CharSequence dateString, CharSequence... formats)

参数说明

参数名类型说明
dateStringCharSequence需要转换的日期字符串
formatsCharSequence...日期字符串的可能格式

返回值

若解析失败则返回 LocalTime.MIN,否则返回一个 LocalTime 实例。

toDate(LocalDateTime date)

方法签名

public static Date toDate(LocalDateTime date)

参数说明

参数名类型说明
dateLocalDateTime需要转换的 LocalDateTime 对象

返回值

返回一个 Date 实例。

toDate(LocalDate date)

方法签名

public static Date toDate(LocalDate date)

参数说明

参数名类型说明
dateLocalDate需要转换的 LocalDate 对象

返回值

返回一个 Date 实例。

toDate(Number timestamp)

方法签名

public static Date toDate(Number timestamp)

参数说明

参数名类型说明
timestampNumber需要转换的时间戳

返回值

返回一个 Date 实例。

toDate(CharSequence dateString)

方法签名

public static Date toDate(CharSequence dateString)

参数说明

参数名类型说明
dateStringCharSequence需要转换的日期字符串

返回值

返回一个 Date 实例。

toDate(CharSequence dateString, CharSequence... formats)

方法签名

public static Date toDate(CharSequence dateString, CharSequence... formats)

参数说明

参数名类型说明
dateStringCharSequence需要转换的日期字符串
formatsCharSequence...日期字符串的可能格式

返回值

返回一个 Date 实例。

toString(LocalDateTime date)

方法签名

String toString(LocalDateTime date)

参数说明

参数名类型说明
dateLocalDateTime需要转换的日期时间对象

返回值

返回一个 String 实例,表示日期时间的 ISO-8601 格式字符串。

toString(LocalDate date)

方法签名

String toString(LocalDate date)

参数说明

参数名类型说明
dateLocalDate需要转换的日期对象

返回值

返回一个 String 实例,表示日期的 ISO-8601 格式字符串。

toString(Date date)

方法签名

String toString(Date date)

参数说明

参数名类型说明
dateDate需要转换的日期时间对象

返回值

返回一个 String 实例,表示日期时间的 ISO-8601 格式字符串。

toString(LocalDateTime date, String format)

方法签名

String toString(LocalDateTime date, String format)

参数说明

参数名类型说明
dateLocalDateTime需要转换的日期时间对象
formatString日期时间的格式

返回值

返回一个 String 实例,表示按照指定格式转换的日期时间字符串。

toString(LocalDate date, String format)

方法签名

String toString(LocalDate date, String format)

参数说明

参数名类型说明
dateLocalDate需要转换的日期对象
formatString日期的格式

返回值

返回一个 String 实例,表示按照指定格式转换的日期字符串。

toString(Date date, String format)

方法签名

String toString(Date date, String format)

参数说明

参数名类型说明
dateDate需要转换的日期时间对象
formatString日期时间的格式

返回值

返回一个 String 实例,表示按照指定格式转换的日期时间字符串。

addTime(LocalDateTime date, int hours, int minutes, int seconds)

方法签名

LocalDateTime addTime(LocalDateTime date, int hours, int minutes, int seconds)

参数说明

参数名类型说明
dateLocalDateTime需要增加时间的日期时间对象
hoursint需要增加的小时数
minutesint需要增加的分钟数
secondsint需要增加的秒数

返回值

返回一个 LocalDateTime 实例,表示增加指定时间后的日期时间。

addTime(Date date, int hours, int minutes, int seconds)

方法签名

Date addTime(Date date, int hours, int minutes, int seconds)

参数说明

参数名类型说明
dateDate需要增加时间的日期时间对象
hoursint需要增加的小时数
minutesint需要增加的分钟数
secondsint需要增加的秒数

返回值

返回一个 Date 实例,表示增加指定时间后的日期时间。

setTime(LocalDateTime date, int hours, int minutes, int seconds)

方法签名

LocalDateTime setTime(LocalDateTime date, int hours, int minutes, int seconds)

参数说明

参数名类型说明
dateLocalDateTime需要设置时间的日期时间对象
hoursint需要设置的小时数
minutesint需要设置的分钟数
secondsint需要设置的秒数

返回值

返回一个 LocalDateTime 实例,表示设置指定时间后的日期时间。

setTime(Date date, int hours, int minutes, int seconds)

方法签名

Date setTime(Date date, int hours, int minutes, int seconds)

参数说明

参数名类型说明
dateDate需要设置时间的日期时间对象
hoursint需要设置的小时数
minutesint需要设置的分钟数
secondsint需要设置的秒数

返回值

返回一个 Date 实例,表示设置指定时间后的日期时间。

addDays(Date date, int days)

方法签名

Date addDays(Date date, int days)

参数说明

参数名类型说明
dateDate需要增加天数的日期对象
daysint需要增加的天数

返回值

返回一个 Date 实例,表示增加指定天数后的日期。

getTimestamp()

方法签名

Long getTimestamp()

参数说明

返回值

返回一个 Long 实例,表示当前时间的时间戳(13 位,即毫秒级)。

getTimestamp(Date date)

方法签名

Long getTimestamp(Date date)

参数说明

参数名类型说明
dateDate需要获取时间戳的日期对象

返回值

返回一个 Long 实例,表示指定日期的时间戳(13 位,即毫秒级)。

getTimestamp(LocalDateTime date)

方法签名

Long getTimestamp(LocalDateTime date)

参数说明

参数名类型说明
dateLocalDateTime需要获取时间戳的日期时间对象

返回值

返回一个 Long 实例,表示指定日期时间的时间戳(13 位,即毫秒级)。

getTimestamp(LocalDate date)

方法签名

Long getTimestamp(LocalDate date)

参数说明

参数名类型说明
dateLocalDate需要获取时间戳的日期对象

返回值

返回一个 Long 实例,表示指定日期的时间戳(13 位,即毫秒级)。

getUnixTimestamp()

方法签名

Long getUnixTimestamp()

参数说明

返回值

返回一个 Long 实例,表示当前时间的 UNIX 时间戳(10 位,即秒级)。

getUnixTimestamp(Date date)

方法签名

Long getUnixTimestamp(Date date)

参数说明

参数名类型说明
dateDate需要获取 UNIX 时间戳的日期对象

返回值

返回一个 Long 实例,表示指定日期的 UNIX 时间戳(10 位,即秒级)。

getUnixTimestamp(LocalDateTime date)

方法签名

Long getUnixTimestamp(LocalDateTime date)

参数说明

参数名类型说明
dateLocalDateTime需要获取 UNIX 时间戳的日期时间对象

返回值

返回一个 Long 实例,表示指定日期时间的 UNIX 时间戳(10 位,即秒级)。

getUnixTimestamp(LocalDate date)

方法签名

Long getUnixTimestamp(LocalDate date)

参数说明

参数名类型说明
dateLocalDate需要获取 UNIX 时间戳的日期对象

返回值

返回一个 Long 实例,表示指定日期的 UNIX 时间戳(10 位,即秒级)。

getYearStartDay(LocalDate date)

方法签名

LocalDate getYearStartDay(LocalDate date)

参数说明

参数名类型说明
dateLocalDate需要获取当年第一天的日期对象

返回值

返回一个 LocalDate 实例,表示指定日期当年第一天的日期。

getYearStartDay(LocalDateTime date)

方法签名

LocalDate getYearStartDay(LocalDateTime date)

参数说明

参数名类型说明
dateLocalDateTime需要获取当年第一天的日期时间对象

返回值

返回一个 LocalDate 实例,表示指定日期时间当年第一天的日期。

getYearEndDay(LocalDate date)

方法签名

LocalDate getYearEndDay(LocalDate date)

参数说明

参数名类型说明
dateLocalDate需要获取当年最后一天的日期对象

返回值

返回一个 LocalDate 实例,表示指定日期当年最后一天的日期。

getYearEndDay(LocalDateTime date)

方法签名

LocalDate getYearEndDay(LocalDateTime date)

参数说明

参数名类型说明
dateLocalDateTime需要获取当年最后一天的日期时间对象

返回值

返回一个 LocalDate 实例,表示指定日期时间当年最后一天的日期。

getYearStart(LocalDateTime date)

方法签名

LocalDateTime getYearStart(LocalDateTime date)

参数说明

参数名类型说明
dateLocalDateTime需要获取当年第一天 0 时的日期时间对象

返回值

返回一个 LocalDateTime 实例,表示指定日期时间当年第一天 0 时的日期时间。

getYearStart(LocalDate date)

方法签名

LocalDateTime getYearStart(LocalDate date)

参数说明

参数名类型说明
dateLocalDate需要获取当年第一天 0 时的日期对象

返回值

返回一个 LocalDateTime 实例,表示指定日期当年第一天 0 时的日期时间。

getYearEnd(LocalDateTime date)

方法签名

LocalDateTime getYearEnd(LocalDateTime date)

参数说明

参数名类型说明
dateLocalDateTime需要获取当年最后一天最后一刻的日期时间对象

返回值

返回一个 LocalDateTime 实例,表示指定日期时间当年最后一天最后一刻的日期时间。

getYearEnd(LocalDate date)

方法签名

LocalDateTime getYearEnd(LocalDate date)

参数说明

参数名类型说明
dateLocalDate需要获取当年最后一天最后一刻的日期对象

返回值

返回一个 LocalDateTime 实例,表示指定日期当年最后一天最后一刻的日期时间。

getMonthStartDay(LocalDate date)

方法签名

LocalDate getMonthStartDay(LocalDate date)

参数说明

参数名类型说明
dateLocalDate需要获取当月第一天的日期对象

返回值

返回一个 LocalDate 实例,表示指定日期当月第一天的日期。

getMonthEndDay(LocalDate date)

方法签名

LocalDate getMonthEndDay(LocalDate date)

参数说明

参数名类型说明
dateLocalDate需要获取当月最后一天的日期对象

返回值

返回一个 LocalDate 实例,表示指定日期当月最后一天的日期。

getMonthStart(LocalDateTime date)

方法签名

LocalDateTime getMonthStart(LocalDateTime date)

参数说明

参数名类型说明
dateLocalDateTime需要获取当月第一天 0 时的日期时间对象

返回值

返回一个 LocalDateTime 实例,表示指定日期时间当月第一天 0 时的日期时间。

getMonthStart(LocalDate date)

方法签名

LocalDateTime getMonthStart(LocalDate date)

参数说明

参数名类型说明
dateLocalDate需要获取当月第一天 0 时的日期对象

返回值

返回一个 LocalDateTime 实例,表示指定日期时间当月第一天 0 时的日期时间。

getMonthEnd(LocalDateTime date)

方法签名

public static LocalDateTime getMonthEnd(LocalDateTime date)

参数说明

参数名类型说明
dateLocalDateTime需要获取月份结束时间的日期时间

返回值

返回一个 LocalDateTime 实例,表示指定日期所在月份的结束时间。

getMonthEnd(LocalDate date)

方法签名

public static LocalDateTime getMonthEnd(LocalDate date)

参数说明

参数名类型说明
dateLocalDate需要获取月份结束时间的日期

返回值

返回一个 LocalDateTime 实例,表示指定日期所在月份的结束时间。

getWeekStartDay(LocalDate date)

方法签名public static LocalDate getWeekStartDay(LocalDate date)

参数说明

参数名类型说明
dateLocalDate需要获取当周周一的日期对象

返回值

返回一个 LocalDate 实例,表示指定日期当周周一的日期。

getWeekEndDay(LocalDate date)

方法签名public static LocalDate getWeekEndDay(LocalDate date)

参数说明

参数名类型说明
dateLocalDate需要获取当周周日的日期对象

返回值

返回一个 LocalDate 实例,表示指定日期当周周日的日期。

getWeekStart(LocalDateTime date)

方法签名public static LocalDateTime getWeekStart(LocalDateTime date)

参数说明

参数名类型说明
dateLocalDateTime需要获取当周周一的日期时间对象

返回值

返回一个 LocalDateTime 实例,表示指定日期当周周一的日期时间。

getWeekEnd(LocalDateTime date)

方法签名public static LocalDateTime getWeekEnd(LocalDateTime date)

参数说明

参数名类型说明
dateLocalDateTime需要获取当周周日的日期时间对象

返回值

返回一个 LocalDateTime 实例,表示指定日期当周周日的日期时间。

getDayStart(LocalDateTime date)

方法签名

public static LocalDateTime getDayStart(LocalDateTime date)

参数说明

参数名类型说明
dateLocalDateTime需要获取开始时间的日期

返回值

返回一个 LocalDateTime 实例,表示指定日期的开始时间。

getDayStart(LocalDate date)

方法签名

public static LocalDateTime getDayStart(LocalDate date)

参数说明

参数名类型说明
dateLocalDate需要获取开始时间的日期

返回值

返回一个 LocalDateTime 实例,表示指定日期的开始时间。

getDayEnd(LocalDateTime date)

方法签名

public static LocalDateTime getDayEnd(LocalDateTime date)

参数说明

参数名类型说明
dateLocalDateTime需要获取结束时间的日期

返回值

返回一个 LocalDateTime 实例,表示指定日期的结束时间。

getDayEnd(LocalDate date)

方法签名

public static LocalDateTime getDayEnd(LocalDate date)

参数说明

参数名类型说明
dateLocalDate需要获取结束时间的日期

返回值

返回一个 LocalDateTime 实例,表示指定日期的结束时间。

getThisYearStart()

方法签名

public static LocalDateTime getThisYearStart()

参数说明 无参数

返回值

返回一个 LocalDateTime 实例,表示当前年份的开始时间。

getThisYearEnd()

方法签名

public static LocalDateTime getThisYearEnd()

参数说明 无参数

返回值

返回一个 LocalDateTime 实例,表示当前年份的结束时间。

getThisMonthStart()

方法签名

public static LocalDateTime getThisMonthStart()

参数说明 无参数

返回值

返回一个 LocalDateTime 实例,表示当前月份的开始时间。

getThisMonthEnd()

方法签名

public static LocalDateTime getThisMonthEnd()

参数说明 无参数

返回值

返回一个 LocalDateTime 实例,表示当前月份的结束时间。

getTodayStart()

方法签名

public static LocalDateTime getTodayStart()

参数说明 无参数

返回值

返回一个 LocalDateTime 实例,表示今天的开始时间。

getTodayEnd()

方法签名

public static LocalDateTime getTodayEnd()

参数说明 无参数

返回值

返回一个 LocalDateTime 实例,表示今天的结束时间。

getLastYearStart()

方法签名public static LocalDateTime getLastYearStart()

返回值

返回一个 LocalDateTime 实例,表示去年的第一天开始时间。

getLastYearEnd()

方法签名public static LocalDateTime getLastYearEnd()

返回值

返回一个 LocalDateTime 实例,表示去年的最后一天最后一刻。

getLastMonthStart(LocalDate date)

方法签名public static LocalDateTime getLastMonthStart(LocalDate date)

参数说明

参数名类型说明
dateLocalDate需要获取上个月开始时间的日期对象

返回值

返回一个 LocalDateTime 实例,表示指定日期上个月第一天的开始时间。

getLastMonthStart(LocalDateTime date)

方法签名public static LocalDateTime getLastMonthStart(LocalDateTime date)

参数说明

参数名类型说明
dateLocalDateTime需要获取上个月开始时间的日期时间对象

返回值

返回一个 LocalDateTime 实例,表示指定日期上个月第一天的开始时间。

getLastMonthEnd(LocalDate date)

方法签名public static LocalDateTime getLastMonthEnd(LocalDate date)

参数说明

参数名类型说明
dateLocalDate需要获取上个月结束时间的日期对象

返回值

返回一个 LocalDateTime 实例,表示指定日期上个月最后一天的最后一刻。

getLastMonthEnd(LocalDateTime date)

方法签名public static LocalDateTime getLastMonthEnd(LocalDateTime date)

参数说明

参数名类型说明
dateLocalDateTime需要获取上个月结束时间的日期时间对象

返回值

返回一个 LocalDateTime 实例,表示指定日期上个月最后一天的最后一刻。

getThisWeekday(LocalDate date, Integer weekday)

方法签名public static LocalDate getThisWeekday(LocalDate date, Integer weekday)

参数说明

参数名类型说明
dateLocalDate需要获取工作日的基准日期
weekdayInteger1-7 依次表示周一至周日

返回值

返回一个 LocalDate 实例,表示指定日期当周对应的星期几。

getThisWeekday(LocalDateTime date, Integer weekday)

方法签名public static LocalDate getThisWeekday(LocalDateTime date, Integer weekday)

参数说明

参数名类型说明
dateLocalDateTime需要获取工作日的基准日期时间
weekdayInteger1-7 依次表示周一至周日

返回值

返回一个 LocalDate 实例,表示指定日期时间当周对应的星期几。

getNextWeekday(LocalDate date, Integer weekday)

方法签名public static LocalDate getNextWeekday(LocalDate date, Integer weekday)

参数说明

参数名类型说明
dateLocalDate需要计算下一个星期几的基准日期
weekdayInteger1-7 依次表示周一至周日

返回值

返回一个 LocalDate 实例,表示指定日期当周或下周的目标星期几。

getPrevWeekday(LocalDate date, Integer weekday)

方法签名public static LocalDate getPrevWeekday(LocalDate date, Integer weekday)

参数说明

参数名类型说明
dateLocalDate需要计算上一个星期几的基准日期
weekdayInteger1-7 依次表示周一至周日

返回值

返回一个 LocalDate 实例,表示指定日期当周或上周的目标星期几。

getNextWeekday(Integer weekday)

方法签名public static LocalDate getNextWeekday(Integer weekday)

参数说明

参数名类型说明
weekdayInteger1-7 依次表示周一至周日

返回值

返回一个 LocalDate 实例,表示相对今天的下一个目标星期几。

getPrevWeekday(Integer weekday)

方法签名public static LocalDate getPrevWeekday(Integer weekday)

参数说明

参数名类型说明
weekdayInteger1-7 依次表示周一至周日

返回值

返回一个 LocalDate 实例,表示相对今天的上一个目标星期几。

getCurrentDate()

方法签名

public static Date getCurrentDate()

参数说明 无参数

返回值

返回一个 Date 实例,表示当前日期时间。

today()

方法签名

public static LocalDate today()

参数说明 无参数

返回值

返回一个 LocalDate 实例,表示今天的日期。

now()

方法签名

public static LocalDateTime now()

参数说明 无参数

返回值

返回一个 LocalDateTime 实例,表示当前的日期时间。