Package org.aoju.bus.core.date
Class Almanac
java.lang.Object
org.aoju.bus.core.date.Formatter
org.aoju.bus.core.date.Converter
org.aoju.bus.core.date.Almanac
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CalendarbeginOfDay(Calendar calendar) 修改某天的开始时间static DateTimebeginOfDay(Date date) 获取某天的开始时间static CalendarbeginOfHour(Calendar calendar) 修改某小时的开始时间static DateTimebeginOfHour(Date date) 获取某小时的开始时间static CalendarbeginOfMinute(Calendar calendar) 获取某分钟的开始时间static DateTimebeginOfMinute(Date date) 获取某分钟的开始时间static CalendarbeginOfMonth(Calendar calendar) 修改某月的开始时间static DateTimebeginOfMonth(Date date) 获取某月的开始时间static CalendarbeginOfQuarter(Calendar calendar) 修改某季度的开始时间static DateTimebeginOfQuarter(Date date) 获取某季度的开始时间static CalendarbeginOfSecond(Calendar calendar) 修改秒级别的开始时间,即忽略毫秒部分static DateTimebeginOfSecond(Date date) 获取秒级别的开始时间,即忽略毫秒部分static CalendarbeginOfWeek(Calendar calendar) 修改给定日期当前周的开始时间,周一定为一周的开始时间static CalendarbeginOfWeek(Calendar calendar, boolean isMondayAsFirstDay) 修改给定日期当前周的开始时间static DateTimebeginOfWeek(Date date) 获取某周的开始时间,周一定为一周的开始时间static CalendarbeginOfYear(Calendar calendar) 修改某年的开始时间static DateTimebeginOfYear(Date date) 获取某年的开始时间static longbetween(Date beginDate, Date endDate, Fields.Units units) 判断两个日期相差的时长,只保留绝对值static longbetween(Date beginDate, Date endDate, Fields.Units units, boolean isAbs) 判断两个日期相差的时长static longbetweenDay(Date beginDate, Date endDate, boolean isReset) 判断两个日期相差的天数static longbetweenDays(LocalDate startInclusive, LocalDate endExclusive) 获取2个日期的相差年月天的天数 比如2020-02-29 2021-03-06,返回6static longbetweenDays(LocalDateTime startInclusive, LocalDateTime endExclusive) 获取2个日期的相差年月天的天数 比如2020-02-29 2021-03-07,返回7static longbetweenDays(Date startInclusive, Date endExclusive) 获取2个日期的相差年月天的天数 比如2020-02-29 2021-03-06,返回6static longbetweenMonth(Date beginDate, Date endDate, boolean isReset) 计算两个日期相差月数 在非重置情况下,如果起始日期的天大于结束日期的天,月数要少算1(不足1个月)static longbetweenMonths(LocalDate startInclusive, LocalDate endExclusive) 获取2个日期的相差年月天的月数 比如2020-02-29 2021-03-07,返回0static longbetweenMonths(LocalDateTime startInclusive, LocalDateTime endExclusive) 获取2个日期的相差年月天的月数 比如2020-02-29 2021-03-07,返回0static longbetweenMonths(Date startInclusive, Date endExclusive) 获取2个日期的相差年月天的月数 比如2020-02-29 2021-03-07,返回0static long判断两个日期相差的毫秒数static longbetweenNextSameMonthDay(LocalDate localDate1, int month, int dayOfMonth) 下个固定月日相差天数,用于生日,节日等周期性的日期推算static longbetweenNextSameMonthDay(LocalDate localDate, String monthDayStr) 下个固定月日相差天数,用于生日,节日等周期性的日期推算static longbetweenNextSameMonthDay(Date date, String monthDayStr) 下个固定月日相差天数,用于生日,节日等周期性的日期推算static longbetweenNextSameMonthDayOfNow(String monthDayStr) 下个固定月日相差天数,与当前日期对比,用于生日,节日等周期性的日期推算static longbetweenTotalDays(LocalDateTime startInclusive, LocalDateTime endExclusive) 获取2个日期的相差总天数static longbetweenTotalDays(Date startInclusive, Date endExclusive) 获取2个日期的相差总天数static longbetweenTotalHours(LocalDateTime startInclusive, LocalDateTime endExclusive) 获取2个日期的相差总小时数static longbetweenTotalHours(LocalTime startInclusive, LocalTime endExclusive) 获取2个日期的相差总小时数static longbetweenTotalHours(Date startInclusive, Date endExclusive) 获取2个日期的相差总小时数static longbetweenTotalMillis(LocalDateTime startInclusive, LocalDateTime endExclusive) 获取2个日期的相差总毫秒数static longbetweenTotalMillis(LocalTime startInclusive, LocalTime endExclusive) 获取2个日期的相差总毫秒数static longbetweenTotalMillis(Date startInclusive, Date endExclusive) 获取2个日期的相差总毫秒数static longbetweenTotalMinutes(LocalDateTime startInclusive, LocalDateTime endExclusive) 获取2个日期的相差总分钟数static longbetweenTotalMinutes(LocalTime startInclusive, LocalTime endExclusive) 获取2个日期的相差总分钟数static longbetweenTotalMinutes(Date startInclusive, Date endExclusive) 获取2个日期的相差总分钟数static longbetweenTotalNanos(LocalDateTime startInclusive, LocalDateTime endExclusive) 获取2个日期的相差总纳秒数static longbetweenTotalNanos(LocalTime startInclusive, LocalTime endExclusive) 获取2个日期的相差总纳秒数static longbetweenTotalNanos(Date startInclusive, Date endExclusive) 获取2个日期的相差总纳秒数static longbetweenTotalSeconds(LocalDateTime startInclusive, LocalDateTime endExclusive) 获取2个日期的相差总秒数static longbetweenTotalSeconds(LocalTime startInclusive, LocalTime endExclusive) 获取2个日期的相差总秒数static longbetweenTotalSeconds(Date startInclusive, Date endExclusive) 获取2个日期的相差总秒数static longbetweenYear(Date beginDate, Date endDate, boolean isReset) 计算两个日期相差年数 在非重置情况下,如果起始日期的月大于结束日期的月,年数要少算1(不足1年)static longbetweenYears(LocalDate startInclusive, LocalDate endExclusive) 获取2个日期的相差年月天的年数 比如2020-02-29 2021-03-07,返回1static longbetweenYears(LocalDateTime startInclusive, LocalDateTime endExclusive) 获取2个日期的相差年月天的年数 比如2020-02-29 2021-03-07,返回1static longbetweenYears(Date startInclusive, Date endExclusive) 获取2个日期的相差年月天的年数 比如2020-02-29 2021-03-07,返回1static Calendarceiling(Calendar calendar, int dateField, Fields.Modify modify) 修改日期static Calendarceiling(Calendar calendar, int field, Fields.Modify modify, boolean truncateMillisecond) 修改日期,取起始值或者结束值可选是否归零毫秒。static Calendarceiling(Calendar calendar, Fields.Type type) 修改日期为某个时间字段结束时间static DateTimeceiling(Date date, Fields.Type type) 修改日期为某个时间字段结束时间static intcompare(long date) 两个时间比较(时间戳比较)static boolean两个时间比较(时间戳比较)static int比较2个时间,可用于LocalDateTime,LocalDate,LocalTime,Instantstatic int两个时间比较static int比较2个时间Datestatic DateTimedate()转换为DateTime对象static DateTimedate(long date) Long类型时间转为DateTime只支持毫秒级别时间戳,如果需要秒级别时间戳,请自行×1000Lstatic DateTimedate(TemporalAccessor temporalAccessor) static DateTimestatic DateTimestatic DurationdurationBetween(Temporal startInclusive, Temporal endExclusive) 获取2个日期的总的天时分秒毫秒纳秒static DateendAccuracyTimeOfDate(Date date) 获localDateTime结束时间,精确时间到纳秒 23:59:59.999000000 (转换为Date会丢失毫秒以后数据)static LocalTime一天结束时间 精确时间到纳秒 23:59:59.999999999static LocalDateTimeendAccuracyTimeOfLocalDateTime(LocalDateTime localDateTime) 获取localDateTime结束时间,精确时间到纳秒 23:59:59.999999999static Calendar修改某天的结束时间static DateTime获取某天的结束时间static Calendar修改某小时的结束时间static DateTime获取某小时的结束时间static CalendarendOfMinute(Calendar calendar) 获取某分钟的结束时间static DateTimeendOfMinute(Date date) 获取某分钟的结束时间static CalendarendOfMonth(Calendar calendar) 修改某月的结束时间static DateTimeendOfMonth(Date date) 获取某月的结束时间static CalendarendOfQuarter(Calendar calendar) 修改某季度的结束时间static DateTimeendOfQuarter(Date date) 获取某季度的结束时间static CalendarendOfSecond(Calendar calendar) 修改秒级别的结束时间,即毫秒设置为999static DateTimeendOfSecond(Date date) 获取秒级别的结束时间,即毫秒设置为999static Calendar修改某周的结束时间,周日定为一周的结束static Calendar修改某周的结束时间static DateTime获取某周的结束时间static Calendar修改某年的结束时间static DateTime获取某年的结束时间static Date获取当前季度结束日期的时间static Date获取当前年结束日期的时间static DateendTimeOfDate(int year, int month, int dayOfMonth) 获取指定日期的结束时间static DateendTimeOfDate(Date date) 获取date结束时间 精确到秒 23:59:59static LocalTime一天开始时间 23:59:59static DateendTimeOfFirstQuarter(int year) 获取第一季度结束日期的开始时间static DateendTimeOfFourthQuarter(int year) 获取第四季度结束日期的开始时间static Date上个月最后一天结束时间 即:上个月最后一天日期+23:59:59static Date当月最后一天结束时间即:当月最后一天日期+23:59:59static DateendTimeOfSecondQuarter(int year) 获取第二季度结束日期的开始时间static DateendTimeOfSpecialMonth(int year, int month) 获取指定年月的最后一天结束时间static DateendTimeOfThirdQuarter(int year) 获取第三季度结束日期的开始时间static Date今天结束时间即:今天日期+23:59:59static Date明天结束时间即:明天日期+23:59:59static DateendTimeOfYear(int year) 获取指定年结束日期的开始时间static Date昨天结束时间即:昨天日期+23:59:59static LocalDatefirstDayOfMonth(LocalDate localDate) 获取当前月的第一天static LocalDateTimefirstDayOfMonth(LocalDateTime localDateTime) 获取当前月的第一天static DatefirstDayOfMonth(Date date) 获取当前月的第一天static intgetAge(long birthDay, long dateToCompare) 计算相对于dateToCompare的年龄,长用于计算指定生日在某年的年龄static int出生日期转年龄static String计算年龄, 返回几周岁几个月几天static int计算年龄static intgetAge(LocalDateTime birthDay) 计算年龄static int计算相对于dateToCompare的年龄,长用于计算指定生日在某年的年龄static int计算年龄static int计算相对于dateToCompare的年龄,长用于计算指定生日在某年的年龄static StringgetAnimal(int year) 获取生肖名称static String通过生日计算生肖,只计算1900年后出生的人static String通过生日计算生肖,只计算1900年后出生的人static intgetBeginValue(Calendar calendar, int dateField) 获取指定日期字段的最小值,例如分钟的最小值是0static String获取当前时间对应的十二时辰static StringgetChrono(LocalDateTime localDateTime) 获取指定时间对应的十二时辰static String获取指定时间对应的十二时辰static String获取指定时间对应的十二时辰static DategetDate(int year, int month, int dayOfMonth) 根据年月日创建Date,时间部分为:00:00:00static DategetDate(int year, int month, int dayOfMonth, int hour, int minute, int second) 根据年月日时分秒创建Datestatic DategetDate(int year, int month, int dayOfMonth, int hour, int minute, int second, int milliOfSecond) 根据年月日时分秒毫秒创建Datestatic DategetDateEndOfMonth(int year, int month) 获取指定月最后一天getDateList(int year, int month) 获取指定年月的所有日期列表getDateList(String yearMonthStr) 获取指定年月的所有日期列表getDateList(Date startInclusive, Date endInclusive) 获取指定区间的时间列表,包含起始static DategetDateStartOfMonth(int year, int month) 获取指定月第一天static StringgetDayOfMonth(int lunarDay) 获取农历日的表示static intgetDayOfMonth(int month, boolean isLeapYear) 获得指定月份的总天数static intgetDayOfMonth(Instant instant) 获取天static intgetDayOfMonth(LocalDate localDate) 获取天 LocalDateTime LocalDate ZonedDateTime 可以直接.getDayOfMonth()static intgetDayOfMonth(LocalDateTime localDateTime) 获取天 LocalDateTime LocalDate ZonedDateTime 可以直接.getDayOfMonth()static intgetDayOfMonth(Date date) 获取天static intgetDayOfWeek(Instant instant) 获取星期值 1-7,星期一到星期日static intgetDayOfWeek(LocalDate localDate) 获取星期值 1-7,星期一到星期日static intgetDayOfWeek(LocalDateTime localDateTime) 获取星期值 1-7,星期一到星期日static intgetDayOfWeek(Date date) 获取星期值 1-7,星期一到星期日static StringgetDayOfWeekCn(Instant instant) 获取星期中文,比如星期一static StringgetDayOfWeekCn(LocalDate localDate) 获取星期中文,比如星期一static StringgetDayOfWeekCn(LocalDateTime localDateTime) 获取星期中文,比如星期一static StringgetDayOfWeekCn(Date date) 获取星期中文,比如星期一static StringgetDayOfWeekCnShort(Instant instant) 获取星期中文简称,比如星期一为一static StringgetDayOfWeekCnShort(LocalDate localDate) 获取星期中文简称,比如星期一为一static StringgetDayOfWeekCnShort(LocalDateTime localDateTime) 获取星期中文简称,比如星期一为一static StringgetDayOfWeekCnShort(Date date) 获取星期中文简称,比如星期一为一static StringgetDayOfWeekEnLong(Instant instant) 获取星期英文全称,比如Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sundaystatic StringgetDayOfWeekEnLong(LocalDate localDate) 获取星期英文全称,比如Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sundaystatic StringgetDayOfWeekEnLong(LocalDateTime localDateTime) 获取星期英文全称,比如Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sundaystatic StringgetDayOfWeekEnLong(Date date) 获取星期英文全称,比如Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sundaystatic StringgetDayOfWeekEnShort(Instant instant) 获取星期英文简称,比如Monstatic StringgetDayOfWeekEnShort(LocalDate localDate) 获取星期英文简称,比如Monstatic StringgetDayOfWeekEnShort(LocalDateTime localDateTime) 获取星期英文简称,比如Monstatic StringgetDayOfWeekEnShort(Date date) 获取星期英文简称,比如Monstatic StringgetDayOfWeekEnShortUpper(Instant instant) 获取星期英文简称大写,比如MONstatic StringgetDayOfWeekEnShortUpper(LocalDate localDate) 获取星期英文简称大写,比如MONstatic StringgetDayOfWeekEnShortUpper(LocalDateTime localDateTime) 获取星期英文简称大写,比如MONstatic StringgetDayOfWeekEnShortUpper(Date date) 获取星期英文简称大写,比如MONstatic int获取当前时间在一年中的第几天static intgetDayOfYear(Instant instant) 获取天(一年中)static intgetDayOfYear(LocalDate localDate) 获取天(一年中) LocalDateTime LocalDate ZonedDateTime 可以直接.getDayOfYear()获取static intgetDayOfYear(LocalDateTime localDateTime) 获取天(一年中) LocalDateTime LocalDate ZonedDateTime 可以直接.getDayOfYear()获取static intgetDayOfYear(Date date) 获取天(一年中)static intgetEndValue(Calendar calendar, int dateField) 获取指定日期字段的最大值,例如分钟的最大值是59static long获取时间戳static String获取格式化时间戳字符串static String获取格式化时间戳字符串,带毫秒static String获取格式化时间戳字符串 iso格式 带毫秒 2020-02-18T22:37:55.991+0800static String获取格式化时间戳字符串 iso格式 2020-02-18T22:37:55+0800static long获取时间戳(到秒)static int获取小时static intgetHour(LocalDateTime localDateTime) 获取小时 LocalDateTime LocalTime ZonedDateTime 可以直接.getHour()获取static int获取小时 LocalDateTime LocalTime ZonedDateTime 可以直接.getHour()获取static int获取小时static intgetInterval(Date start, Date end) 获取两个日期段相差的周数计算去年同期和上期的起止时间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计算时间段内的所有的天 type:0本期1上期2去年同期(年)计算本期(年)的上期static intgetLastDayOfMonth(Date date) 获得本月的最后一天static intgetLengthOfYear(int year) 获取某年的总天数getLocalDateList(int year, int month) 获取指定年月的所有日期列表getLocalDateList(String yearMonthStr) 获取指定年月的所有日期列表getLocalDateList(LocalDate startInclusive, LocalDate endInclusive) 获取指定区间的时间列表,包含起始getLocalDateList(YearMonth yearMonth) 获取指定年月的所有日期列表static List<LocalDateTime> getLocalDateTimeList(int year, int month) 获取指定年月的所有日期列表static List<LocalDateTime> getLocalDateTimeList(String yearMonthStr) 获取指定年月的所有日期列表static List<LocalDateTime> getLocalDateTimeList(LocalDateTime startInclusive, LocalDateTime endInclusive) 获取指定区间的时间列表,包含起始static List<LocalDateTime> getLocalDateTimeList(YearMonth yearMonth) 获取指定年月的所有日期列表static intgetMillisecond(Instant instant) 获取毫秒static intgetMillisecond(LocalDateTime localDateTime) 获取毫秒static intgetMillisecond(LocalTime localTime) 获取毫秒static intgetMillisecond(ZonedDateTime zonedDateTime) 获取毫秒static intgetMillisecond(Date date) 获取毫秒static int获取分钟static intgetMinute(LocalDateTime localDateTime) 获取分钟 LocalDateTime LocalTime ZonedDateTime 可以直接.getMinute()获取static int获取分钟 LocalDateTime LocalTime ZonedDateTime 可以直接.getMinute()获取static int获取分钟static StringgetMonth(int month) 获取农历月份(月)计算本期的上期和去年同期 1 上期 2同期 返回的mapkay beginkey endkey 本期起止:begin end 计算上期的起止时间 和去年同期 type 0本期 1上期 2去年同期当时间段内的所有月份static int获取月, 比如 1static int获取月, 比如 1 LocalDateTime LocalDate ZonedDateTime 可以直接getMonthValue()static intgetMonth(LocalDateTime localDateTime) 获取月, 比如 1 LocalDateTime LocalDate ZonedDateTime 可以直接getMonthValue()static int获取月, 比如 1static StringgetMonthCnLong(Instant instant) 获取月份中文全称, 比如一月static StringgetMonthCnLong(LocalDate localDate) 获取月份中文全称, 比如一月static StringgetMonthCnLong(LocalDateTime localDateTime) 获取月份中文全称, 比如一月static StringgetMonthCnLong(Date date) 获取月份中文全称, 比如一月static StringgetMonthCnShort(Instant instant) 获取月份中文简称, 比如一static StringgetMonthCnShort(LocalDate localDate) 获取月份中文简称, 比如一static StringgetMonthCnShort(LocalDateTime localDateTime) 获取月份中文简称, 比如一static StringgetMonthCnShort(Date date) 获取月份中文简称, 比如一static StringgetMonthEnLong(Instant instant) 获取月英文全称, 比如 Januarystatic StringgetMonthEnLong(LocalDate localDate) 获取月英文全称, 比如 Januarystatic StringgetMonthEnLong(LocalDateTime localDateTime) 获取月英文全称, 比如 Januarystatic StringgetMonthEnLong(Date date) 获取月英文全称, 比如 Januarystatic StringgetMonthEnShort(Instant instant) 获取月英文简称, 比如 Janstatic StringgetMonthEnShort(LocalDate localDate) 获取月英文简称, 比如 Janstatic StringgetMonthEnShort(LocalDateTime localDateTime) 获取月英文简称, 比如 Janstatic StringgetMonthEnShort(Date date) 获取月英文简称, 比如 Janstatic StringgetMonthEnShortUpper(Instant instant) 获取月英文简称大写, 比如 JANstatic StringgetMonthEnShortUpper(LocalDate localDate) 获取月英文简称大写, 比如 JANstatic StringgetMonthEnShortUpper(LocalDateTime localDateTime) 获取月英文简称大写, 比如 JANstatic StringgetMonthEnShortUpper(Date date) 获取月英文简称大写, 比如 JANstatic intgetMonthOfQuarter(int quarter) 根据季度返回季度第一月static StringgetMonthOfQuarter(int type, int quarter) 根据季度返回季度第一月或最后一月 0 起始月 1截止月static int获得当前季度值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去年同期 季度static LinkedHashSet<String> getQuarter(long startDate, long endDate) 获得指定日期区间内的年份和季节getQuarter(String StartDate, String beginQ, String endDate, String endQ) (季度)获取季度份时间段内的所有季度static intgetQuarter(LocalDate localDate) 获得季度值static intgetQuarter(LocalDateTime localDateTime) 获得季度值static intgetQuarter(Date date) 获得季度值static LinkedHashSet<String> getQuarter(Date startDate, Date endDate) 获得指定日期区间内的年份和季节static intgetQuarterOfMonth(int month) 根据月份获取所在季度static int获取秒static intgetSecond(LocalDateTime localDateTime) 获取秒 LocalDateTime LocalTime ZonedDateTime 可以直接.getSecond()获取static int获取秒 LocalDateTime LocalTime ZonedDateTime 可以直接.getSecond()获取static int获取秒static int返回该年有多少个自然周(周)返回起止时间内的所有自然周static int获取两个日期段相差的周数static int计算指定指定时间区间内的周数获取年份时间段内的所有年static int获取年,比如2020static int获取年,比如2020 LocalDateTime LocalDate ZonedDateTime 可以直接getYear()static intgetYear(LocalDateTime localDateTime) 获取年,比如2020 LocalDateTime LocalDate ZonedDateTime 可以直接getYear()static int获取年,比如2020static StringgetZodiac(int month, int day) 通过生日计算星座static String通过生日计算星座static String通过生日计算星座static StringgetZodiacCnName(String monthDay) 根据日期查询星座中文名称static StringgetZodiacCnName(Date date) 根据日期查询星座中文名称static StringgetZodiacEnName(String monthDay) 根据日期查询星座英文名称static StringgetZodiacEnName(Date date) 根据日期查询星座中文名称static ZonedDateTimegetZonedDateTimeNow(String zoneId) 获取时区当前时间static ZonedDateTime获取当前上海时区时间(北京时间)static ZonedDateTime获取当前系统当前时区时间static ZonedDateTime获取当前巴黎时区时间static ZonedDateTime获取当前美国东部标准时区static ZonedDateTime获取当前东京时区时间static boolean是否为上午static boolean是否为上午static boolean校验前面的日期go,是否早于或者等于后面的日期backstatic boolean校验前面的日期go,是否早于或者等于后面的日期backstatic booleanisBirthday(int year, int month, int day) 验证是否为生日static booleanisBirthday(CharSequence value) 验证是否为生日 只支持以下几种格式: yyyyMMdd yyyy-MM-dd yyyy/MM/dd yyyy.MM.dd yyyy年MM月dd日static booleanisBirthDay(LocalDate localDate) 是否为生日static booleanisBirthDay(LocalDateTime localDateTime) 是否为生日static booleanisBirthDay(Date date) 是否为生日static boolean校验日期格式,日期不能早于当前天, 默认日期转义格式:yyyy-MM-ddstatic boolean校验日期格式,日期不能早于当前天static booleanisDatetime(String datetime) 验证长日期格式yyyy-MM-dd HH:mm:ssstatic boolean判断是否过期,(输入年月小于当前年月)static boolean判断是否过期,(输入年月小于当前年月)static boolean是否为周五static boolean是否为周五static booleanisIn(ChronoLocalDateTime<?> beginDate, ChronoLocalDateTime<?> endDate) 判断当前时间(默认时区)是否在指定范围内 起始时间和结束时间可以互换static booleanisIn(TemporalAccessor date, TemporalAccessor beginDate, TemporalAccessor endDate) 判断指定时间是否在指定范围内 起始日期和结束日期可以互换static booleanisIn(TemporalAccessor date, TemporalAccessor beginDate, TemporalAccessor endDate, boolean includeBegin, boolean includeEnd) 判断指定时间是否在指定范围内 起始日期和结束日期可以互换 通过includeBegin, includeEnd参数控制日期范围区间是否为开区间, 例如:传入参数:includeBegin=true, includeEnd=false, 则本方法会判断 date (beginDate, endDate) 是否成立static boolean判断当前时间(默认时区)是否在指定范围内 起始日期和结束日期可以互换static boolean判定在指定检查时间是否过期 起始日期和结束日期可以互换static booleanisLastDayOfMonth(Date date) 是否为本月最后一天static booleanisLeapYear(int year) 判断是否闰年static booleanisLeapYear(LocalDate localDate) 判断是否闰年static booleanisLeapYear(LocalDateTime localDateTime) 判断是否闰年static booleanisLeapYear(Date date) 判断是否闰年static boolean是否为周一static boolean是否为周一static booleanisNotLessThanToday(String date) 判断传入的日期是否 >=今天static booleanisNotLessThanToday(String date, String format) 判断传入的日期是否>=今天static boolean检查两个时间段是否有时间重叠 重叠指两个时间段是否有交集,注意此方法时间段重合时如: 此方法未纠正开始时间小于结束时间 当realStartTime和realEndTime或startTime和endTime相等时,退化为判断区间是否包含点 当realStartTime和realEndTime和startTime和endTime相等时,退化为判断点与点是否相等 See 准确的区间关系参考:艾伦区间代数static boolean是否为下午static boolean是否为下午static boolean比较两个日期是否为同一天static booleanisSameDay(LocalDateTime date1, LocalDateTime date2) 比较两个日期是否为同一天static boolean比较两个日期是否为同一天static boolean比较两个日期是否为同一天static booleanisSameMonth(Calendar cal1, Calendar cal2) 比较两个日期是否为同一月static booleanisSameMonth(Date date1, Date date2) 比较两个日期是否为同一月static booleanisSameMonthDay(LocalDate localDate1, String monthDayStr) 相同月日比较判断,用于生日,节日等周期性的日期比较判断static booleanisSameMonthDay(LocalDate localDate1, LocalDate localDate2) 相同月日比较判断,用于生日,节日等周期性的日期比较判断。static booleanisSameMonthDay(LocalDate localDate1, MonthDay monthDay) 相同月日比较判断,用于生日,节日等周期性的日期比较判断static booleanisSameMonthDay(Date date, String monthDayStr) 相同月日比较判断,用于生日,节日等周期性的日期比较判断。static booleanisSameMonthDay(Date date1, Date date2) 相同月日比较判断,用于生日,节日等周期性的日期比较判断。static booleanisSameMonthDayOfNow(String monthDayStr) 相同月日比较判断,与当前日期对比,用于生日,节日等周期性的日期比较判断static booleanisSameTime(Calendar date1, Calendar date2) 检查两个Calendar时间戳是否相同 此方法检查两个Calendar的毫秒数时间戳是否相同static booleanisSameTime(Date date1, Date date2) 是否为相同时间 此方法比较两个日期的时间戳是否相同static booleanisSameWeek(Calendar cal1, Calendar cal2, boolean isMon) 比较两个日期是否为同一周static booleanisSameWeek(Date date1, Date date2, boolean isMon) 比较两个日期是否为同一周static booleanisShortDate(String date) 校验短日期格式[yyyyMMdd]static boolean判断是否周末(周六周日)static booleanisWeekend(LocalDateTime localDateTime) 判断是否周末(周六周日)static boolean判断是否周末(周六周日)static boolean判断是否工作日 (周一到周五)static booleanisWorkDay(LocalDateTime localDateTime) 判断是否工作日 (周一到周五)static boolean判断是否工作日 (周一到周五)static LocalDatelastDayOfMonth(LocalDate localDate) 获取当前月的最后一天static LocalDateTimelastDayOfMonth(LocalDateTime localDateTime) 获取当前月的最后一天static DatelastDayOfMonth(Date date) 获取当前月的最后一天static Date上月日期static DatelastWeek()上周日期static DatelastYear()去年日期static intlengthOfMonth(LocalDate localDate) 获取月的天数static intlengthOfMonth(LocalDateTime localDateTime) 获取月的天数static intlengthOfMonth(Date date) 获取月的天数static intlengthOfYear(LocalDate localDate) 获取年的天数static intlengthOfYear(LocalDateTime localDateTime) 获取年的天数static intlengthOfYear(Date date) 获取年的天数static LocalDate下一个星期几static LocalDateTimenext(LocalDateTime localDateTime, DayOfWeek dayOfWeek) 下一个星期几static Date下一个星期几static intnextLeapYear(int year) 下一个闰年static LocalDatenextLeapYear(LocalDate localDate) 下一个闰年static LocalDateTimenextLeapYear(LocalDateTime localDateTime) 下一个闰年static DatenextLeapYear(Date date) 下一个闰年static Date下月日期static LocalDatenextSameMonthDay(LocalDate localDate, String monthDayStr) 下个固定月日相差日期,用于生日,节日等周期性的日期推算static DatenextSameMonthDay(Date date, String monthDayStr) 下个固定月日相差日期,用于生日,节日等周期性的日期推算static DatenextSameMonthDayOfNow(String monthDayStr) 下个固定月日相差日期,与当前日期对比,用于生日,节日等周期性的日期推算static DatenextWeek()下周日期static TemporalAdjuster下一个工作日static LocalDatenextWorkDay(LocalDate localDate) 获下一个工作日static LocalDateTimenextWorkDay(LocalDateTime localDateTime) 获下一个工作日static DatenextWorkDay(Date date) 获下一个工作日static DatenextYear()明年日期static Stringnow()当前时间,格式 yyyy-MM-dd HH:mm:ssstatic DateTimeoffset(Date date, Fields.Type type, int offset) 获取指定日期偏移指定时间后的时间static DateTime偏移天static DateTimeoffsetHour(Date date, int offset) 偏移小时static DateTimeoffsetMillisecond(Date date, int offset) 偏移毫秒数static DateTimeoffsetMinute(Date date, int offset) 偏移分钟static DateTimeoffsetMonth(Date date, int offset) 偏移月static DateTimeoffsetSecond(Date date, int offset) 偏移秒数static DateTimeoffsetWeek(Date date, int offset) 偏移周static DateTimeoffsetYear(Date date, int offset) 偏移月static PeriodperiodBetween(LocalDate startDateInclusive, LocalDate endDateExclusive) 获取2个日期的相差年月日部分属性static LocalDate上一个星期几static LocalDateTimeprevious(LocalDateTime localDateTime, DayOfWeek dayOfWeek) 上一个星期几static Date上一个星期几static LocalDateTimereduceAccuracyToDay(LocalDateTime localDateTime) 减少时间精度到天,其他补0,返回如,2020-04-23 00:00:00static DatereduceAccuracyToDay(Date date) 减少时间精度到天,其他补0,返回如,2020-04-23 00:00:00static LocalDateTimereduceAccuracyToHour(LocalDateTime localDateTime) 减少时间精度到小时,其他补0,返回如,2020-04-23 15:00:00static DatereduceAccuracyToHour(Date date) 减少时间精度到小时,其他补0,返回如,2020-04-23 15:00:00static LocalDateTimereduceAccuracyToMinute(LocalDateTime localDateTime) 减少时间精度到分,其他补0,返回如,2020-04-23 15:18:00static DatereduceAccuracyToMinute(Date date) 减少时间精度到分,其他补0,返回如,2020-04-23 15:18:00static LocalDateTimereduceAccuracyToSecond(LocalDateTime localDateTime) 减少时间精度到秒,其他补0,返回如,2020-04-23 15:18:13static DatereduceAccuracyToSecond(Date date) 减少时间精度到秒,其他补0,返回如,2020-04-23 15:18:13static Calendarround(Calendar calendar, Fields.Type type) 修改日期为某个时间字段四舍五入时间static DateTimeround(Date date, Fields.Type type) 修改日期为某个时间字段四舍五入时间static Date获取当前季度起始日期的开始时间static Date获取当前年起始日期的开始时间static DatestartTimeOfDate(int year, int month, int dayOfMonth) 获取指定日期的起始时间static DatestartTimeOfDate(Date date) 获date起始时间static LocalTime一天开始时间 00:00:00static DatestartTimeOfFirstQuarter(int year) 获取第一季度起始日期的开始时间static DatestartTimeOfFourthQuarter(int year) 获取第四季度起始日期的开始时间static Date上个月第一天起始时间 即:上个月第一天日期+00:00:00static LocalDateTimestartTimeOfLocalDateTime(LocalDateTime localDateTime) 获localDateTime起始时间static Date当月第一天起始时间 即:当月第一天日期+00:00:00static DatestartTimeOfSecondQuarter(int year) 获取第二季度起始日期的开始时间static DatestartTimeOfSpecialMonth(int year, int month) 获取指定年月的第一天起始时间static DatestartTimeOfThirdQuarter(int year) 获取第三季度起始日期的开始时间static Date今天起始时间 即:今天日期+00:00:00static Date明天起始时间 即:明天日期+00:00:00static DatestartTimeOfYear(int year) 获取指定年起始日期的开始时间static Date昨天起始时间 即:昨天日期+00:00:00static int当前月份static intthisWeek()当前日期是星期几static intthisYear()当前年份static long当前时间毫秒数static longtimestamp(boolean isNano) 当前时间longstatic Stringtoday()当前日期,格式 yyyy-MM-ddstatic Datetomorrow()明天日期static ZonedDateTimetransform(ZonedDateTime zonedDateTime, String zoneId) 时区转换计算static ZonedDateTimetransform(ZonedDateTime zonedDateTime, ZoneId zone) 时区转换计算static String时区转换计算static String时区转换计算static Calendartruncate(Calendar calendar, Fields.Type type) 修改日期为某个时间字段起始时间static DateTimetruncate(Date date, Fields.Type type) 修改日期为某个时间字段起始时间static int当前日期所在月中第几周static intweekOfMonth(LocalDate localDate) 日期所在月中第几周static intweekOfMonth(LocalDate localDate, Locale locale) 日期所在月中第几周static intweekOfMonth(LocalDateTime localDateTime) 日期所在月中第几周static intweekOfMonth(Date date) 日期所在月中第几周static int当前日期所在年中第几周static intweekOfYear(LocalDate localDate) 日期所在年中第几周static intweekOfYear(LocalDate localDate, Locale locale) 日期所在年中第几周static intweekOfYear(LocalDateTime localDateTime) 日期所在年中第几周static intweekOfYear(Date date) 日期所在年中第几周static Temporalwith(Temporal temporal, TemporalField field, long newValue) 根据field修改属性static Datewith(Date date, TemporalField field, long newValue) 根据field修改属性static Date原有时间基础上,加上/减去(负数)N天static LocalDatewithDayOfMonth(LocalDate localDate, long newValue) 修改天static LocalDateTimewithDayOfMonth(LocalDateTime localDateTime, long newValue) 修改天static DatewithDayOfMonth(Date date, long newValue) 修改天static LocalDatewithDayOfWeek(LocalDate localDate, long newValue) 修改星期static LocalDateTimewithDayOfWeek(LocalDateTime localDateTime, long newValue) 修改星期static DatewithDayOfWeek(Date date, long newValue) 修改星期static LocalDatewithDayOfYear(LocalDate localDate, long newValue) 修改一年中的天static LocalDateTimewithDayOfYear(LocalDateTime localDateTime, long newValue) 修改一年中的天static DatewithDayOfYear(Date date, long newValue) 修改一年中的天static LocalDateTimewithHour(LocalDateTime localDateTime, long newValue) 修改小时static LocalTime修改小时static Date原有时间基础上,加上/减去(负数)N小时static Date修改小时static LocalDateTimewithMilli(LocalDateTime localDateTime, long newValue) 修改毫秒static LocalTime修改毫秒static Date原有时间基础上,加上/减去(负数)N毫秒static Date修改毫秒static LocalDateTimewithMinute(LocalDateTime localDateTime, long newValue) 修改分钟static LocalTimewithMinute(LocalTime localTime, long newValue) 修改分钟static DatewithMinute(Date date, int newValue) 原有时间基础上,加上/减去(负数)N分钟static DatewithMinute(Date date, long newValue) 修改分钟static LocalDate修改月static LocalDateTimewithMonth(LocalDateTime localDateTime, long newValue) 修改月static Date原有时间基础上,加上/减去(负数)N月static LocalDateTimewithSecond(LocalDateTime localDateTime, long newValue) 修改秒static LocalTimewithSecond(LocalTime localTime, long newValue) 修改秒static DatewithSecond(Date date, int newValue) 原有时间基础上,加上/减去(负数)N秒static DatewithSecond(Date date, long newValue) 修改秒static Date原有时间基础上,加上/减去(负数)N周static LocalDate修改年static LocalDateTimewithYear(LocalDateTime localDateTime, long newValue) 修改年static Date原有时间基础上,加上/减去(负数)N年static Date修改年static Date昨天日期Methods inherited from class org.aoju.bus.core.date.Converter
toCalendar, 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, newSimpleFormat, newSimpleFormat, parse, parse, parse, parse, parse, parse, parse, parse, parseByPatterns, parseByPatterns, parseByPatterns, parseByPatterns
-
Constructor Details
-
Almanac
public Almanac()
-
-
Method Details
-
getYear
-
getYear
-
getYear
获取年,比如2020 LocalDateTime LocalDate ZonedDateTime 可以直接getYear()- Parameters:
localDateTime- LocalDateTime- Returns:
- int
-
getYear
获取年,比如2020 LocalDateTime LocalDate ZonedDateTime 可以直接getYear()- Parameters:
localDate- localDate- Returns:
- int
-
getYear
-
getQuarter
获得指定日期区间内的年份和季节- Parameters:
startDate- 起始日期(包含)endDate- 结束日期(包含)- Returns:
- 季度列表 ,元素类似于 20132
-
getQuarter
获得指定日期区间内的年份和季节- 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- 开始时间keyendkey- 截止时间keybeginWkey- 开始周keyendWkey- 截止周keybegin- 开始时间end- 截止时间beginW- 开始周endW- 截止周- Returns:
- the map
-
getQuarter
-
getMonth
-
getMonth
-
getMonth
-
getMonth
获取月, 比如 1 LocalDateTime LocalDate ZonedDateTime 可以直接getMonthValue()- Parameters:
localDateTime- LocalDateTime- Returns:
- int
-
getMonth
获取月, 比如 1 LocalDateTime LocalDate ZonedDateTime 可以直接getMonthValue()- Parameters:
localDate- LocalDate- Returns:
- int
-
getMonth
-
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- 开始时间keyendkey- 截止时间keybegin- 开始时间end- 截止时间- Returns:
- the map
-
getMonthEnLong
-
getMonthEnLong
-
getMonthEnLong
获取月英文全称, 比如 January- Parameters:
localDateTime- LocalDateTime- Returns:
- String
-
getMonthEnLong
-
getMonthEnShort
-
getMonthEnShort
-
getMonthEnShort
获取月英文简称, 比如 Jan- Parameters:
localDateTime- LocalDateTime- Returns:
- String
-
getMonthEnShort
-
getMonthEnShortUpper
-
getMonthEnShortUpper
-
getMonthEnShortUpper
获取月英文简称大写, 比如 JAN- Parameters:
localDateTime- LocalDateTime- Returns:
- String
-
getMonthEnShortUpper
-
getMonthCnLong
-
getMonthCnLong
-
getMonthCnLong
获取月份中文全称, 比如一月- Parameters:
localDateTime- LocalDateTime- Returns:
- String
-
getMonthCnLong
-
getMonthCnShort
-
getMonthCnShort
-
getMonthCnShort
获取月份中文简称, 比如一- Parameters:
localDateTime- LocalDateTime- Returns:
- String
-
getMonthCnShort
-
getMonthOfQuarter
public static int getMonthOfQuarter(int quarter) 根据季度返回季度第一月- Parameters:
quarter- 季度- Returns:
- 月份
-
getMonthOfQuarter
根据季度返回季度第一月或最后一月 0 起始月 1截止月- Parameters:
type- 第一个月份quarter- 季度- Returns:
- 月份
-
getQuarterOfMonth
public static int getQuarterOfMonth(int month) 根据月份获取所在季度- Parameters:
month- 月份- Returns:
- 季度
-
getWeek
-
getWeek
返回该年有多少个自然周- Parameters:
year- 最多53 一般52 如果12月月末今天在本年53周(属于第二年第一周) 那么按照当年52周算- Returns:
- the int
-
getWeek
-
getDayOfMonth
获取农历日的表示- Parameters:
lunarDay- 农历日数值表示- Returns:
- 农历日传统字符表示
-
getDayOfMonth
public static int getDayOfMonth(int month, boolean isLeapYear) 获得指定月份的总天数- Parameters:
month- 月份isLeapYear- 是否闰年- Returns:
- 天
-
getDayOfMonth
-
getDayOfMonth
-
getDayOfMonth
获取天 LocalDateTime LocalDate ZonedDateTime 可以直接.getDayOfMonth()- Parameters:
localDateTime- LocalDateTime- Returns:
- int
-
getDayOfMonth
获取天 LocalDateTime LocalDate ZonedDateTime 可以直接.getDayOfMonth()- Parameters:
localDate- localDate- Returns:
- int
-
getDayOfYear
-
getDayOfYear
-
getDayOfYear
获取天(一年中) LocalDateTime LocalDate ZonedDateTime 可以直接.getDayOfYear()获取- Parameters:
localDateTime- LocalDateTime- Returns:
- int
-
getDayOfYear
获取天(一年中) 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
-
getHour
-
getHour
获取小时 LocalDateTime LocalTime ZonedDateTime 可以直接.getHour()获取- Parameters:
localDateTime- LocalDateTime- Returns:
- int
-
getHour
获取小时 LocalDateTime LocalTime ZonedDateTime 可以直接.getHour()获取- Parameters:
localTime- localTime- Returns:
- int
-
getMinute
-
getMinute
-
getMinute
获取分钟 LocalDateTime LocalTime ZonedDateTime 可以直接.getMinute()获取- Parameters:
localDateTime- LocalDateTime- Returns:
- int
-
getMinute
获取分钟 LocalDateTime LocalTime ZonedDateTime 可以直接.getMinute()获取- Parameters:
localTime- localTime- Returns:
- int
-
getSecond
-
getSecond
-
getSecond
获取秒 LocalDateTime LocalTime ZonedDateTime 可以直接.getSecond()获取- Parameters:
localDateTime- LocalDateTime- Returns:
- int
-
getSecond
获取秒 LocalDateTime LocalTime ZonedDateTime 可以直接.getSecond()获取- Parameters:
localTime- localTime- Returns:
- int
-
getMillisecond
-
getMillisecond
-
getMillisecond
获取毫秒- Parameters:
localDateTime- LocalDateTime- Returns:
- int
-
getMillisecond
获取毫秒- Parameters:
localTime- localTime- Returns:
- int
-
getMillisecond
获取毫秒- Parameters:
zonedDateTime- zonedDateTime- Returns:
- int
-
getEpochMilli
public static long getEpochMilli()获取时间戳- Returns:
- long
-
getEpochSecond
public static long getEpochSecond()获取时间戳(到秒)- Returns:
- long
-
getEpochMilliFormat
-
getEpochMilliFormatFull
获取格式化时间戳字符串,带毫秒- Returns:
- String 格式: yyyy-MM-dd HH:mm:ss.SSS
-
getEpochMilliIsoNotFormatNoColon
获取格式化时间戳字符串 iso格式 2020-02-18T22:37:55+0800- Returns:
- String 格式: yyyy-MM-ddTHH:mm:ssZ
-
getEpochMilliIsoFormatFullNoColon
获取格式化时间戳字符串 iso格式 带毫秒 2020-02-18T22:37:55.991+0800- Returns:
- String 格式: yyyy-MM-dd'T'HH:mm:ss.SSSZ
-
getDate
根据年月日创建Date,时间部分为:00:00:00- Parameters:
year- 年month- 月dayOfMonth- 日- Returns:
- Date
-
getDate
根据年月日时分秒创建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
获取指定月第一天- Parameters:
year- 年month- 月- Returns:
- Date
-
getDateEndOfMonth
获取指定月最后一天- Parameters:
year- 年month- 月- Returns:
- Date
-
getAge
-
getAge
-
getAge
-
getAge
-
getAge
-
getAge
-
getAge
public static int getAge(long birthDay, long dateToCompare) 计算相对于dateToCompare的年龄,长用于计算指定生日在某年的年龄- Parameters:
birthDay- 生日dateToCompare- 需要对比的日期- Returns:
- 年龄
-
getAge
-
getQuarter
获得季度值- Parameters:
localDateTime- LocalDateTime- Returns:
- int 季度 1,2,3,4
-
getQuarter
获得季度值- Parameters:
localDate- LocalDate- Returns:
- int 季度 1,2,3,4
-
getQuarter
-
getQuarter
public static int getQuarter()获得当前季度值- Returns:
- int 季度 1,2,3,4
-
getLast
-
getLast
-
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- 开始时间keyendkey- 截止时间keybeginWkey- 开始周keyendWkey- 截止周keybegin- 开始时间end- 截止时间beginW- 开始周endW- 截止周- Returns:
- the map
-
getLast
-
getInterval
-
getWeeks
-
withYear
-
withYear
修改年- Parameters:
localDateTime- LocalDateTimenewValue- 新值- Returns:
- LocalDateTime
-
withYear
-
withYear
-
withMonth
修改月- Parameters:
localDateTime- LocalDateTimenewValue- 新值- Returns:
- LocalDateTime
-
withMonth
-
withMonth
-
withWeek
-
withDay
-
withHour
-
withHour
修改小时- Parameters:
localDateTime- LocalDateTimenewValue- 新值- Returns:
- LocalDateTime
-
withHour
-
withHour
-
withMinute
-
withMinute
修改分钟- Parameters:
localDateTime- LocalDateTimenewValue- 新值- Returns:
- LocalDateTime
-
withMinute
-
withMinute
-
withSecond
-
withSecond
修改秒- Parameters:
localDateTime- LocalDateTimenewValue- 新值- Returns:
- LocalDateTime
-
withSecond
-
withSecond
-
withMilli
-
withMilli
修改毫秒- Parameters:
localDateTime- LocalDateTimenewValue- 新值- Returns:
- LocalDateTime
-
withMilli
-
withMilli
-
withDayOfMonth
-
withDayOfMonth
修改天- Parameters:
localDateTime- LocalDateTimenewValue- 新值- Returns:
- LocalDateTime
-
withDayOfMonth
-
withDayOfYear
-
withDayOfYear
修改一年中的天- Parameters:
localDateTime- LocalDateTimenewValue- 新值- Returns:
- LocalDateTime
-
withDayOfYear
-
withDayOfWeek
-
withDayOfWeek
修改星期- Parameters:
localDateTime- LocalDateTimenewValue- 新值 1-7- Returns:
- LocalDateTime
-
withDayOfWeek
-
betweenYears
获取2个日期的相差年月天的年数 比如2020-02-29 2021-03-07,返回1- Parameters:
startInclusive- 开始时间endExclusive- 结束时间- Returns:
- long
-
betweenYears
-
betweenYears
-
betweenMonths
获取2个日期的相差年月天的月数 比如2020-02-29 2021-03-07,返回0- Parameters:
startInclusive- 开始时间endExclusive- 结束时间- Returns:
- long
-
betweenMonths
-
betweenMonths
-
betweenDays
获取2个日期的相差年月天的天数 比如2020-02-29 2021-03-07,返回7- Parameters:
startInclusive- 开始时间endExclusive- 结束时间- Returns:
- long
-
betweenDays
-
betweenDays
-
betweenTotalDays
获取2个日期的相差总天数- Parameters:
startInclusive- 开始时间endExclusive- 结束时间- Returns:
- long
-
betweenTotalDays
-
betweenTotalHours
获取2个日期的相差总小时数- Parameters:
startInclusive- 开始时间endExclusive- 结束时间- Returns:
- long
-
betweenTotalHours
-
betweenTotalHours
-
betweenTotalMinutes
获取2个日期的相差总分钟数- Parameters:
startInclusive- 开始时间endExclusive- 结束时间- Returns:
- long
-
betweenTotalMinutes
-
betweenTotalMinutes
-
betweenTotalSeconds
获取2个日期的相差总秒数- Parameters:
startInclusive- 开始时间endExclusive- 结束时间- Returns:
- long
-
betweenTotalSeconds
-
betweenTotalSeconds
-
betweenTotalMillis
获取2个日期的相差总毫秒数- Parameters:
startInclusive- 开始时间endExclusive- 结束时间- Returns:
- long
-
betweenTotalMillis
-
betweenTotalMillis
-
betweenTotalNanos
获取2个日期的相差总纳秒数- Parameters:
startInclusive- 开始时间endExclusive- 结束时间- Returns:
- long
-
betweenTotalNanos
-
betweenTotalNanos
-
getDayOfWeek
-
getDayOfWeek
获取星期值 1-7,星期一到星期日- Parameters:
localDateTime- LocalDateTime- Returns:
- int
-
getDayOfWeek
获取星期值 1-7,星期一到星期日- Parameters:
localDate- LocalDate- Returns:
- int
-
getDayOfWeek
获取星期值 1-7,星期一到星期日- Parameters:
instant- Instant- Returns:
- int
-
getDayOfWeekEnLong
-
getDayOfWeekEnLong
获取星期英文全称,比如Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday- Parameters:
localDateTime- LocalDateTime- Returns:
- String
-
getDayOfWeekEnLong
-
getDayOfWeekEnLong
-
getDayOfWeekEnShort
-
getDayOfWeekEnShort
获取星期英文简称,比如Mon- Parameters:
localDateTime- LocalDateTime- Returns:
- String
-
getDayOfWeekEnShort
-
getDayOfWeekEnShort
-
getDayOfWeekEnShortUpper
-
getDayOfWeekEnShortUpper
获取星期英文简称大写,比如MON- Parameters:
localDateTime- LocalDateTime- Returns:
- String
-
getDayOfWeekEnShortUpper
-
getDayOfWeekEnShortUpper
-
getDayOfWeekCn
-
getDayOfWeekCn
获取星期中文,比如星期一- Parameters:
localDateTime- LocalDateTime- Returns:
- String
-
getDayOfWeekCn
-
getDayOfWeekCn
-
getDayOfWeekCnShort
-
getDayOfWeekCnShort
获取星期中文简称,比如星期一为一- Parameters:
localDateTime- LocalDateTime- Returns:
- String
-
getDayOfWeekCnShort
-
getDayOfWeekCnShort
-
firstDayOfMonth
-
firstDayOfMonth
获取当前月的第一天- Parameters:
localDateTime- LocalDateTime- Returns:
- LocalDateTime
-
firstDayOfMonth
-
lastDayOfMonth
-
lastDayOfMonth
获取当前月的最后一天- Parameters:
localDateTime- LocalDateTime- Returns:
- LocalDateTime
-
lastDayOfMonth
-
beginOfSecond
-
endOfSecond
-
beginOfSecond
-
endOfSecond
-
beginOfMinute
-
endOfMinute
-
beginOfMinute
-
endOfMinute
-
beginOfHour
-
endOfHour
-
beginOfDay
-
endOfDay
-
beginOfHour
-
endOfHour
-
beginOfDay
-
endOfDay
-
beginOfWeek
-
endOfWeek
-
beginOfWeek
-
beginOfWeek
-
endOfWeek
-
endOfWeek
-
beginOfMonth
-
endOfMonth
-
beginOfMonth
-
endOfMonth
-
beginOfQuarter
-
endOfQuarter
-
beginOfQuarter
-
endOfQuarter
-
beginOfYear
-
endOfYear
-
beginOfYear
-
endOfYear
-
isLeapYear
判断是否闰年- Parameters:
localDate- LocalDate- Returns:
- boolean
-
isLeapYear
判断是否闰年- Parameters:
localDateTime- LocalDateTime- Returns:
- boolean
-
isLeapYear
-
isLeapYear
public static boolean isLeapYear(int year) 判断是否闰年- Parameters:
year- 年- Returns:
- boolean
-
nextLeapYear
public static int nextLeapYear(int year) 下一个闰年- Parameters:
year- 年- Returns:
- int
-
nextLeapYear
下一个闰年- Parameters:
localDateTime- LocalDateTime- Returns:
- LocalDateTime
-
nextLeapYear
-
nextLeapYear
-
isWorkDay
-
isWorkDay
判断是否工作日 (周一到周五)- Parameters:
localDateTime- LocalDateTime- Returns:
- boolean
-
isWorkDay
判断是否工作日 (周一到周五)- Parameters:
localDate- LocalDate- Returns:
- boolean
-
isWeekend
-
isWeekend
判断是否周末(周六周日)- Parameters:
localDateTime- LocalDateTime- Returns:
- boolean
-
isWeekend
判断是否周末(周六周日)- Parameters:
localDate- LocalDate- Returns:
- boolean
-
lengthOfMonth
获取月的天数- Parameters:
localDate- LocalDate- Returns:
- int
-
lengthOfMonth
获取月的天数- Parameters:
localDateTime- LocalDateTime- Returns:
- int
-
lengthOfMonth
-
lengthOfYear
获取年的天数- Parameters:
localDate- LocalDate- Returns:
- int
-
lengthOfYear
获取年的天数- Parameters:
localDateTime- LocalDateTime- Returns:
- int
-
lengthOfYear
-
next
-
next
下一个星期几- Parameters:
localDateTime- 日期dayOfWeek- 星期- Returns:
- LocalDateTime
-
next
-
previous
-
previous
上一个星期几- Parameters:
localDateTime- 日期dayOfWeek- 星期- Returns:
- LocalDateTime
-
previous
-
nextWorkDay
-
nextWorkDay
获下一个工作日- Parameters:
localDateTime- LocalDateTime- Returns:
- LocalDateTime
-
nextWorkDay
-
nextWorkDay
-
getZonedDateTimeNowOfDefault
-
getZonedDateTimeNowOfCTT
-
getZonedDateTimeNowOfECT
-
getZonedDateTimeNowOfEST
-
getZonedDateTimeNowOfJST
-
with
根据field修改属性- Parameters:
temporal- Temporalfield- 属性newValue- 新值- Returns:
- Temporal
-
with
根据field修改属性- Parameters:
date- 日期field- 属性newValue- 新值- Returns:
- Date
-
durationBetween
-
periodBetween
-
getZonedDateTimeNow
获取时区当前时间- Parameters:
zoneId- 时区- Returns:
- ZonedDateTime
-
transform
时区转换计算- Parameters:
zonedDateTime- ZonedDateTimezoneId- 例如 Asia/Shanghai- Returns:
- ZonedDateTime
-
transform
时区转换计算- Parameters:
zonedDateTime- ZonedDateTimezone- 时区- Returns:
- ZonedDateTime
-
transform
-
transform
-
compare
-
compare
-
compare
-
compare
public static int compare(long date) 两个时间比较(时间戳比较)- Parameters:
date- 日期- Returns:
- 时间差
-
compare
两个时间比较(时间戳比较)- Parameters:
object- 字符串日期- Returns:
- the boolean
-
startTimeOfDay
-
endTimeOfDay
-
endAccuracyTimeOfDay
-
startTimeOfYesterday
-
endTimeOfYesterday
-
startTimeOfTomorrow
-
endTimeOfTomorrow
-
startTimeOfToday
-
endTimeOfToday
-
startTimeOfLastMonth
-
endTimeOfLastMonth
-
startTimeOfMonth
-
endTimeOfMonth
-
startTimeOfDate
-
endTimeOfDate
-
endAccuracyTimeOfDate
-
startTimeOfLocalDateTime
获localDateTime起始时间- Parameters:
localDateTime- LocalDateTime- Returns:
- LocalDateTime
-
endAccuracyTimeOfLocalDateTime
获取localDateTime结束时间,精确时间到纳秒 23:59:59.999999999- Parameters:
localDateTime- LocalDateTime- Returns:
- LocalDateTime
-
startTimeOfSpecialMonth
获取指定年月的第一天起始时间- Parameters:
year- 年month- 月- Returns:
- Date
-
endTimeOfSpecialMonth
获取指定年月的最后一天结束时间- Parameters:
year- 年month- 月- Returns:
- Date
-
startTimeOfDate
获取指定日期的起始时间- Parameters:
year- 年month- 月dayOfMonth- 日- Returns:
- Date
-
endTimeOfDate
获取指定日期的结束时间- Parameters:
year- 年month- 月dayOfMonth- 日- Returns:
- Date
-
startTimeOfFirstQuarter
获取第一季度起始日期的开始时间- Parameters:
year- 年- Returns:
- Date
-
startTimeOfSecondQuarter
获取第二季度起始日期的开始时间- Parameters:
year- 年- Returns:
- Date
-
startTimeOfThirdQuarter
获取第三季度起始日期的开始时间- Parameters:
year- 年- Returns:
- Date
-
startTimeOfFourthQuarter
获取第四季度起始日期的开始时间- Parameters:
year- 年- Returns:
- Date
-
endTimeOfFirstQuarter
获取第一季度结束日期的开始时间- Parameters:
year- 年- Returns:
- Date
-
endTimeOfSecondQuarter
获取第二季度结束日期的开始时间- Parameters:
year- 年- Returns:
- Date
-
endTimeOfThirdQuarter
获取第三季度结束日期的开始时间- Parameters:
year- 年- Returns:
- Date
-
endTimeOfFourthQuarter
获取第四季度结束日期的开始时间- Parameters:
year- 年- Returns:
- Date
-
startTimeOfCurrentQuarter
-
endTimeOfCurrentQuarter
-
startTimeOfYear
-
endTimeOfYear
-
startTimeOfCurrentYear
-
endTimeOfCurrentYear
-
isSameTime
-
isSameTime
-
isSameDay
-
isSameDay
-
isSameDay
-
isSameDay
比较两个日期是否为同一天- Parameters:
date1- 日期1date2- 日期2- Returns:
- 是否为同一天
-
isSameWeek
-
isSameWeek
-
isSameMonth
-
isSameMonth
-
isSameMonthDay
-
isSameMonthDay
-
isSameMonthDay
-
isSameMonthDay
-
isSameMonthDay
-
isSameMonthDayOfNow
相同月日比较判断,与当前日期对比,用于生日,节日等周期性的日期比较判断- Parameters:
monthDayStr- 月日字符串,MM-dd格式- Returns:
- boolean
-
betweenNextSameMonthDay
下个固定月日相差天数,用于生日,节日等周期性的日期推算- Parameters:
localDate1- 日期1month- 月dayOfMonth- 日- Returns:
- long
-
betweenNextSameMonthDay
-
betweenNextSameMonthDay
-
betweenNextSameMonthDayOfNow
下个固定月日相差天数,与当前日期对比,用于生日,节日等周期性的日期推算- Parameters:
monthDayStr- 月日字符串,MM-dd格式- Returns:
- long
-
nextSameMonthDay
-
nextSameMonthDay
-
nextSameMonthDayOfNow
-
getZodiacCnName
-
getZodiacCnName
-
getZodiacEnName
-
getZodiacEnName
-
getZodiac
-
getZodiac
-
getZodiac
通过生日计算星座- Parameters:
month- 月,从0开始计数day- 天- Returns:
- 星座名
-
getLocalDateTimeList
public static List<LocalDateTime> getLocalDateTimeList(LocalDateTime startInclusive, LocalDateTime endInclusive) 获取指定区间的时间列表,包含起始- Parameters:
startInclusive- 开始时间endInclusive- 结束时间- Returns:
- 时间列表
-
getLocalDateList
-
getLocalDateList
-
getLocalDateList
-
getLocalDateList
-
getLocalDateTimeList
获取指定年月的所有日期列表- Parameters:
yearMonth- 年月- Returns:
- 时间列表
-
getLocalDateTimeList
获取指定年月的所有日期列表- Parameters:
yearMonthStr- 年月字符串,格式: yyyy-MM- Returns:
- 时间列表
-
getLocalDateTimeList
获取指定年月的所有日期列表- Parameters:
year- 年month- 月- Returns:
- 时间列表
-
getDateList
-
getDateList
-
getDateList
-
isExpiry
判断是否过期,(输入年月小于当前年月)- Parameters:
yearMonth- 年月- Returns:
- boolean
-
isExpiry
判断是否过期,(输入年月小于当前年月)- Parameters:
value- 年月字符串,格式: yyyy-MM- Returns:
- boolean
-
isBirthday
验证是否为生日 只支持以下几种格式:- yyyyMMdd
- yyyy-MM-dd
- yyyy/MM/dd
- yyyy.MM.dd
- yyyy年MM月dd日
- Parameters:
value- 值- Returns:
- 是否为生日
-
isBirthDay
-
isBirthDay
是否为生日- Parameters:
localDate- 生日- Returns:
- boolean
-
isBirthDay
是否为生日- Parameters:
localDateTime- 生日- Returns:
- boolean
-
isBirthday
public static boolean isBirthday(int year, int month, int day) 验证是否为生日- Parameters:
year- 年,从1900年开始计算month- 月,从1开始计数day- 日,从1开始计数- Returns:
- 是否为生日
-
reduceAccuracyToSecond
减少时间精度到秒,其他补0,返回如,2020-04-23 15:18:13- Parameters:
localDateTime- LocalDateTime- Returns:
- LocalDateTime
-
reduceAccuracyToSecond
-
reduceAccuracyToMinute
减少时间精度到分,其他补0,返回如,2020-04-23 15:18:00- Parameters:
localDateTime- LocalDateTime- Returns:
- LocalDateTime
-
reduceAccuracyToMinute
-
reduceAccuracyToHour
减少时间精度到小时,其他补0,返回如,2020-04-23 15:00:00- Parameters:
localDateTime- LocalDateTime- Returns:
- LocalDateTime
-
reduceAccuracyToHour
-
reduceAccuracyToDay
减少时间精度到天,其他补0,返回如,2020-04-23 00:00:00- Parameters:
localDateTime- LocalDateTime- Returns:
- LocalDateTime
-
reduceAccuracyToDay
-
weekOfMonth
-
weekOfMonth
日期所在月中第几周- Parameters:
localDate- LocalDate- Returns:
- 周数
-
weekOfMonth
日期所在月中第几周- Parameters:
localDateTime- LocalDateTime- Returns:
- 周数
-
weekOfMonth
-
weekOfMonth
public static int weekOfMonth()当前日期所在月中第几周- Returns:
- 周数
-
weekOfYear
-
weekOfYear
日期所在年中第几周- Parameters:
localDate- LocalDate- Returns:
- 周数
-
weekOfYear
日期所在年中第几周- Parameters:
localDateTime- LocalDateTime- Returns:
- 周数
-
weekOfYear
-
weekOfYear
public static int weekOfYear()当前日期所在年中第几周- Returns:
- 周数
-
isMonday
是否为周一- Parameters:
localDate- LocalDate- Returns:
- 是 true 否 false
-
isMonday
-
isFriday
是否为周五- Parameters:
localDate- LocalDate- Returns:
- 是 true 否 false
-
isFriday
-
isDate
-
isDate
校验日期格式,日期不能早于当前天, 默认日期转义格式:yyyy-MM-dd- Parameters:
dptDate- 日期,仅需包含年月日- Returns:
- true/false
-
isBefore
-
isBefore
-
isDatetime
验证长日期格式yyyy-MM-dd HH:mm:ss- Parameters:
datetime- 日期- Returns:
- true/false
-
isShortDate
校验短日期格式[yyyyMMdd]- Parameters:
date- 短日期- Returns:
- true/false
-
isOverlap
检查两个时间段是否有时间重叠 重叠指两个时间段是否有交集,注意此方法时间段重合时如:- 此方法未纠正开始时间小于结束时间
- 当realStartTime和realEndTime或startTime和endTime相等时,退化为判断区间是否包含点
- 当realStartTime和realEndTime和startTime和endTime相等时,退化为判断点与点是否相等
- Parameters:
realStartTime- 第一个时间段的开始时间realEndTime- 第一个时间段的结束时间startTime- 第二个时间段的开始时间endTime- 第二个时间段的结束时间- Returns:
- true 表示时间有重合或包含或相等
-
isNotLessThanToday
判断传入的日期是否 >=今天- Parameters:
date- 待判断的日期- Returns:
- true/false
-
isNotLessThanToday
-
isAM
-
isAM
-
isPM
-
isPM
-
isIn
-
isIn
-
isIn
判断当前时间(默认时区)是否在指定范围内 起始时间和结束时间可以互换- Parameters:
beginDate- 起始时间(包含)endDate- 结束时间(包含)- Returns:
- 是否在范围内
-
isIn
public static boolean isIn(TemporalAccessor date, TemporalAccessor beginDate, TemporalAccessor endDate) 判断指定时间是否在指定范围内 起始日期和结束日期可以互换- Parameters:
date- 被检查的日期beginDate- 起始日期(包含)endDate- 结束日期(包含)- Returns:
- 是否在范围内
-
isIn
public static boolean isIn(TemporalAccessor date, TemporalAccessor beginDate, TemporalAccessor endDate, boolean includeBegin, boolean includeEnd) 判断指定时间是否在指定范围内 起始日期和结束日期可以互换 通过includeBegin, includeEnd参数控制日期范围区间是否为开区间, 例如:传入参数:includeBegin=true, includeEnd=false, 则本方法会判断 date (beginDate, endDate) 是否成立- Parameters:
date- 被检查的日期beginDate- 起始日期endDate- 结束日期includeBegin- 时间范围是否包含起始日期includeEnd- 时间范围是否包含结束日期- Returns:
- 是否在范围内
-
getChrono
-
getChrono
获取指定时间对应的十二时辰- Parameters:
localDateTime- LocalDateTime- Returns:
- 十二时辰名称
-
getChrono
-
getChrono
-
getAnimal
-
getAnimal
-
getAnimal
-
getBeginValue
获取指定日期字段的最小值,例如分钟的最小值是0- Parameters:
calendar-CalendardateField-Fields.Type- Returns:
- 字段最小值
- See Also:
-
getEndValue
获取指定日期字段的最大值,例如分钟的最大值是59- Parameters:
calendar-CalendardateField-Fields.Type- Returns:
- 字段最大值
- See Also:
-
ceiling
修改日期为某个时间字段结束时间 -
ceiling
修改日期为某个时间字段结束时间 -
ceiling
修改日期 -
ceiling
public static Calendar ceiling(Calendar calendar, int field, Fields.Modify modify, boolean truncateMillisecond) 修改日期,取起始值或者结束值可选是否归零毫秒。 在Fields.Modify.TRUNCATE模式下,毫秒始终要归零, 但是在Fields.Modify.CEILING和Fields.Modify.ROUND模式下 有时候由于毫秒部分必须为0(如MySQL数据库中),因此在此加上选项 -
truncate
修改日期为某个时间字段起始时间 -
truncate
修改日期为某个时间字段起始时间 -
round
修改日期为某个时间字段四舍五入时间 -
round
修改日期为某个时间字段四舍五入时间 -
between
判断两个日期相差的时长,只保留绝对值- Parameters:
beginDate- 起始日期endDate- 结束日期units- 相差的单位- Returns:
- 日期差
-
between
判断两个日期相差的时长- Parameters:
beginDate- 起始日期endDate- 结束日期units- 相差的单位isAbs- 日期间隔是否只保留绝对值正数- Returns:
- 日期差
-
betweenMs
-
betweenDay
-
betweenMonth
-
betweenYear
-
offsetMillisecond
-
offsetSecond
-
offsetMinute
-
offsetHour
-
offsetDay
-
offsetWeek
-
offsetMonth
-
offsetYear
-
offset
获取指定日期偏移指定时间后的时间- Parameters:
date- 基准日期type- 偏移的粒度大小(小时、天、月等)offset- 偏移量,正数为向后偏移,负数为向前偏移- Returns:
- 偏移后的日期
-
isLastDayOfMonth
-
getLastDayOfMonth
-
date
-
date
-
date
-
date
-
date
- Parameters:
temporalAccessor-TemporalAccessor,常用子类:LocalDateTime、 LocalDate,如果传入null,返回null- Returns:
- 时间对象
-
now
-
today
-
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
-
nextWeek
-
nextMonth
-
nextYear
-
yesterday
-
lastWeek
-
lastMonth
-
lastYear
-