Package org.aoju.bus.core.toolkit
Class DateKit
java.lang.Object
org.aoju.bus.core.date.Formatter
org.aoju.bus.core.date.Converter
org.aoju.bus.core.date.Almanac
org.aoju.bus.core.toolkit.DateKit
时间工具类
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int生日转为年龄,计算法定年龄static int生日转为年龄,计算法定年龄static StringgetLastTime(Date date) 返回文字描述的日期getLunar()通过公历构造getLunar(int year, int month, int day) 通过年、月、日构造getLunar(int year, int month, int day, int hour, int minute) 通过年、月、日构造getLunar(int year, int month, int day, int hour, int minute, int second) 通过年、月、日构造通过公历构造getSolar()通过公历构造getSolar(int year, int month, int day) 通过年、月、日构造getSolar(int year, int month, int day, int hour, int minute) 通过年、月、日构造getSolar(int year, int month, int day, int hour, int minute, int second) 通过年、月、日构造通过公历构造static Boundaryrange(Date start, Date end, Fields.Type type) 创建日期范围生成器static voidrangeConsume(Date start, Date end, Fields.Type type, Consumer<Date> consumer) 按日期范围遍历,执行 consumerrangeContains(Boundary start, Boundary end) 两个时间区间取交集static <T> List<T>按日期范围遍历,执行 functionrangeNotContains(Boundary start, Boundary end) 两个时间区间取差集(end - start)rangeToList(Date start, Date end, Fields.Type type) 根据步进单位获取起始日期时间和结束日期时间的时间区间集合rangeToList(Date start, Date end, Fields.Type type, int step) 根据步进单位和步进获取起始日期时间和结束日期时间的时间区间集合static longspendMs(long preTime) 计时,常用于记录某段代码的执行时间,单位:毫秒static longspendNt(long preTime) 计时,常用于记录某段代码的执行时间,单位:纳秒Methods inherited from class org.aoju.bus.core.date.Almanac
beginOfDay, beginOfDay, beginOfHour, beginOfHour, beginOfMinute, beginOfMinute, beginOfMonth, beginOfMonth, beginOfQuarter, beginOfQuarter, beginOfSecond, beginOfSecond, beginOfWeek, beginOfWeek, beginOfWeek, beginOfYear, beginOfYear, between, between, betweenDay, betweenDays, betweenDays, betweenDays, betweenMonth, betweenMonths, betweenMonths, betweenMonths, betweenMs, betweenNextSameMonthDay, betweenNextSameMonthDay, betweenNextSameMonthDay, betweenNextSameMonthDayOfNow, betweenTotalDays, betweenTotalDays, betweenTotalHours, betweenTotalHours, betweenTotalHours, betweenTotalMillis, betweenTotalMillis, betweenTotalMillis, betweenTotalMinutes, betweenTotalMinutes, betweenTotalMinutes, betweenTotalNanos, betweenTotalNanos, betweenTotalNanos, betweenTotalSeconds, betweenTotalSeconds, betweenTotalSeconds, betweenYear, betweenYears, betweenYears, betweenYears, ceiling, ceiling, ceiling, ceiling, compare, compare, compare, compare, compare, date, date, date, date, date, durationBetween, endAccuracyTimeOfDate, endAccuracyTimeOfDay, endAccuracyTimeOfLocalDateTime, endOfDay, endOfDay, endOfHour, endOfHour, endOfMinute, endOfMinute, endOfMonth, endOfMonth, endOfQuarter, endOfQuarter, endOfSecond, endOfSecond, endOfWeek, endOfWeek, endOfWeek, endOfYear, endOfYear, endTimeOfCurrentQuarter, endTimeOfCurrentYear, endTimeOfDate, endTimeOfDate, endTimeOfDay, endTimeOfFirstQuarter, endTimeOfFourthQuarter, endTimeOfLastMonth, endTimeOfMonth, endTimeOfSecondQuarter, endTimeOfSpecialMonth, endTimeOfThirdQuarter, endTimeOfToday, endTimeOfTomorrow, endTimeOfYear, endTimeOfYesterday, firstDayOfMonth, firstDayOfMonth, firstDayOfMonth, getAge, getAge, getAge, getAge, getAge, getAge, getAge, getAge, getAnimal, getAnimal, getAnimal, getBeginValue, getChrono, getChrono, getChrono, getChrono, getDate, getDate, getDate, getDateEndOfMonth, getDateList, getDateList, getDateList, getDateStartOfMonth, getDayOfMonth, getDayOfMonth, getDayOfMonth, getDayOfMonth, getDayOfMonth, getDayOfMonth, getDayOfWeek, getDayOfWeek, getDayOfWeek, getDayOfWeek, getDayOfWeekCn, getDayOfWeekCn, getDayOfWeekCn, getDayOfWeekCn, getDayOfWeekCnShort, getDayOfWeekCnShort, getDayOfWeekCnShort, getDayOfWeekCnShort, getDayOfWeekEnLong, getDayOfWeekEnLong, getDayOfWeekEnLong, getDayOfWeekEnLong, getDayOfWeekEnShort, getDayOfWeekEnShort, getDayOfWeekEnShort, getDayOfWeekEnShort, getDayOfWeekEnShortUpper, getDayOfWeekEnShortUpper, getDayOfWeekEnShortUpper, getDayOfWeekEnShortUpper, getDayOfYear, getDayOfYear, getDayOfYear, getDayOfYear, getDayOfYear, getEndValue, getEpochMilli, getEpochMilliFormat, getEpochMilliFormatFull, getEpochMilliIsoFormatFullNoColon, getEpochMilliIsoNotFormatNoColon, getEpochSecond, getHour, getHour, getHour, getHour, getInterval, getLast, getLast, getLast, getLast, getLengthOfYear, getLocalDateList, getLocalDateList, getLocalDateList, getLocalDateList, getLocalDateTimeList, getLocalDateTimeList, getLocalDateTimeList, getLocalDateTimeList, getMillisecond, getMillisecond, getMillisecond, getMillisecond, getMillisecond, getMinute, getMinute, getMinute, getMinute, getMonth, getMonth, getMonth, getMonth, getMonth, getMonth, getMonth, getMonthCnLong, getMonthCnLong, getMonthCnLong, getMonthCnLong, getMonthCnShort, getMonthCnShort, getMonthCnShort, getMonthCnShort, getMonthEnLong, getMonthEnLong, getMonthEnLong, getMonthEnLong, getMonthEnShort, getMonthEnShort, getMonthEnShort, getMonthEnShort, getMonthEnShortUpper, getMonthEnShortUpper, getMonthEnShortUpper, getMonthEnShortUpper, getMonthOfQuarter, getMonthOfQuarter, getQuarter, getQuarter, getQuarter, getQuarter, getQuarter, getQuarter, getQuarter, getQuarter, getQuarterOfMonth, getSecond, getSecond, getSecond, getSecond, getWeek, getWeek, getWeek, getWeeks, getYear, getYear, getYear, getYear, getYear, getZodiac, getZodiac, getZodiac, getZodiacCnName, getZodiacCnName, getZodiacEnName, getZodiacEnName, getZonedDateTimeNow, getZonedDateTimeNowOfCTT, getZonedDateTimeNowOfDefault, getZonedDateTimeNowOfECT, getZonedDateTimeNowOfEST, getZonedDateTimeNowOfJST, isAM, isAM, isBefore, isBefore, isBirthday, isBirthday, isBirthDay, isBirthDay, isBirthDay, isDate, isDate, isDatetime, isExpiry, isExpiry, isFriday, isFriday, isIn, isIn, isLeapYear, isLeapYear, isLeapYear, isLeapYear, isMonday, isMonday, isNotLessThanToday, isNotLessThanToday, isOverlap, isPM, isPM, isSameDay, isSameDay, isSameDay, isSameDay, isSameMonth, isSameMonth, isSameMonthDay, isSameMonthDay, isSameMonthDay, isSameMonthDay, isSameMonthDay, isSameMonthDayOfNow, isSameTime, isSameTime, isSameWeek, isSameWeek, isShortDate, isWeekend, isWeekend, isWeekend, isWorkDay, isWorkDay, isWorkDay, lastDayOfMonth, lastDayOfMonth, lastDayOfMonth, lastMonth, lastWeek, lastYear, lengthOfMonth, lengthOfMonth, lengthOfMonth, lengthOfYear, lengthOfYear, lengthOfYear, next, next, next, nextLeapYear, nextLeapYear, nextLeapYear, nextLeapYear, nextMonth, nextSameMonthDay, nextSameMonthDay, nextSameMonthDayOfNow, nextWeek, nextWorkDay, nextWorkDay, nextWorkDay, nextWorkDay, nextYear, now, offset, offsetDay, offsetHour, offsetMillisecond, offsetMinute, offsetMonth, offsetSecond, offsetWeek, offsetYear, periodBetween, previous, previous, previous, reduceAccuracyToDay, reduceAccuracyToDay, reduceAccuracyToHour, reduceAccuracyToHour, reduceAccuracyToMinute, reduceAccuracyToMinute, reduceAccuracyToSecond, reduceAccuracyToSecond, round, round, startTimeOfCurrentQuarter, startTimeOfCurrentYear, startTimeOfDate, startTimeOfDate, startTimeOfDay, startTimeOfFirstQuarter, startTimeOfFourthQuarter, startTimeOfLastMonth, startTimeOfLocalDateTime, startTimeOfMonth, startTimeOfSecondQuarter, startTimeOfSpecialMonth, startTimeOfThirdQuarter, startTimeOfToday, startTimeOfTomorrow, startTimeOfYear, startTimeOfYesterday, thisMonth, thisWeek, thisYear, timestamp, timestamp, today, tomorrow, transform, transform, transform, transform, truncate, truncate, weekOfMonth, weekOfMonth, weekOfMonth, weekOfMonth, weekOfMonth, weekOfYear, weekOfYear, weekOfYear, weekOfYear, weekOfYear, with, with, withDay, withDayOfMonth, withDayOfMonth, withDayOfMonth, withDayOfWeek, withDayOfWeek, withDayOfWeek, withDayOfYear, withDayOfYear, withDayOfYear, withHour, withHour, withHour, withHour, withMilli, withMilli, withMilli, withMilli, withMinute, withMinute, withMinute, withMinute, withMonth, withMonth, withMonth, withSecond, withSecond, withSecond, withSecond, withWeek, withYear, withYear, withYear, withYear, yesterdayMethods inherited from class org.aoju.bus.core.date.Converter
toCalendar, toCalendar, toCalendar, toDate, toDate, toDate, toDate, toDate, toDate, toDate, toDateEndOfMonth, toDateStartOfMonth, toEpochMilli, toEpochMilli, toEpochMilli, toEpochMilli, toEpochMilli, toEpochMilli, toEpochMilli, toInstant, toInstant, toInstant, toInstant, toInstant, toInstant, toInstant, toInstant, toInstant, toLocalDate, toLocalDate, toLocalDate, toLocalDate, toLocalDate, toLocalDate, toLocalDate, toLocalDateEndOfMonth, toLocalDateStartOfMonth, toLocalDateTime, toLocalDateTime, toLocalDateTime, toLocalDateTime, toLocalDateTime, toLocalDateTime, toLocalDateTime, toLocalDateTime, toLocalTime, toLocalTime, toLocalTime, toLocalTime, toLocalTime, toSecond, toTime, toTimestamp, toTimestamp, toTimestamp, toTimestamp, toTimeZone, toTimeZone, toYearMonth, toYearMonth, toYearMonth, toYearMonth, toYearMonth, toZonedDateTime, toZonedDateTime, toZonedDateTime, toZonedDateTime, toZonedDateTime, toZonedDateTime, toZonedDateTime, toZonedDateTime, toZonedDateTime, toZonedDateTimeMethods inherited from class org.aoju.bus.core.date.Formatter
format, format, format, format, format, format, format, format, format, format, format, format, format, format, format, format, format, formatBetween, formatBetween, formatBetween, formatBetween, formatDate, formatDate, formatTime, getShotName, isOverlap, newSimpleFormat, newSimpleFormat, parse, parse, parse, parse, parse, parse, parse, parse, parse, parse, parseByPatterns, parseByPatterns, parseByPatterns, parseCST, parseDate, parseDateTime, parseTime, parseTimeToday, parseUTC
-
Constructor Details
-
DateKit
public DateKit()
-
-
Method Details
-
spendNt
public static long spendNt(long preTime) 计时,常用于记录某段代码的执行时间,单位:纳秒- Parameters:
preTime- 之前记录的时间- Returns:
- 时间差, 纳秒
-
spendMs
public static long spendMs(long preTime) 计时,常用于记录某段代码的执行时间,单位:毫秒- Parameters:
preTime- 之前记录的时间- Returns:
- 时间差, 毫秒
-
ageOfNow
生日转为年龄,计算法定年龄- Parameters:
birthDay- 生日,标准日期字符串- Returns:
- 年龄
-
ageOfNow
生日转为年龄,计算法定年龄- Parameters:
birthDay- 生日- Returns:
- 年龄
-
getLastTime
返回文字描述的日期- Parameters:
date- 日期- Returns:
- 日期
-
range
创建日期范围生成器- Parameters:
start- 起始日期时间end- 结束日期时间type- 步进单位- Returns:
Boundary
-
rangeContains
两个时间区间取交集- Parameters:
start- 开始区间end- 结束区间- Returns:
- true 包含
-
rangeNotContains
两个时间区间取差集(end - start)- Parameters:
start- 开始区间end- 结束区间- Returns:
- true 包含
-
rangeFunc
按日期范围遍历,执行 function- Type Parameters:
T- Date经过函数处理结果类型- Parameters:
start- 起始日期时间(包括)end- 结束日期时间type- 步进单位func- 每次遍历要执行的 function- Returns:
- 结果列表
-
rangeConsume
按日期范围遍历,执行 consumer- Parameters:
start- 起始日期时间(包括)end- 结束日期时间type- 步进单位consumer- 每次遍历要执行的 consumer
-
rangeToList
根据步进单位获取起始日期时间和结束日期时间的时间区间集合- Parameters:
start- 起始日期时间end- 结束日期时间type- 步进单位- Returns:
Boundary
-
rangeToList
根据步进单位和步进获取起始日期时间和结束日期时间的时间区间集合- Parameters:
start- 起始日期时间end- 结束日期时间type- 步进单位step- 步进- Returns:
Boundary
-
getLunar
通过公历构造- Returns:
Lunar
-
getLunar
通过公历构造- Parameters:
calendar- 公历日期- Returns:
Lunar
-
getLunar
通过年、月、日构造- Parameters:
year- 农历年month- 农历月份,范围1-12day- 农历日1-30- Returns:
Lunar
-
getLunar
通过年、月、日构造- Parameters:
year- 农历年month- 农历月份,范围1-12day- 农历日1-30hour- 小时minute- 分钟- Returns:
Lunar
-
getLunar
通过年、月、日构造- Parameters:
year- 农历年month- 农历月份,范围1-12day- 农历日1-30hour- 小时minute- 分钟second- 秒- Returns:
Lunar
-
getSolar
通过公历构造- Returns:
Solar
-
getSolar
通过公历构造- Parameters:
calendar- 公历日期- Returns:
Solar
-
getSolar
通过年、月、日构造- Parameters:
year- 农历年month- 农历月份,范围1-12day- 农历日1-30- Returns:
Solar
-
getSolar
通过年、月、日构造- Parameters:
year- 农历年month- 农历月份,范围1-12day- 农历日1-30hour- 小时minute- 分钟- Returns:
Solar
-
getSolar
通过年、月、日构造- Parameters:
year- 农历年month- 农历月份,范围1-12day- 农历日1-30hour- 小时minute- 分钟second- 秒- Returns:
Solar
-