类 DateUtils
- java.lang.Object
-
- cn.hutool.core.date.DateUtil
-
- ai.yue.library.base.util.DateUtils
-
public class DateUtils extends cn.hutool.core.date.DateUtil时间工具类(JDK1.8)- 从以下版本开始:
- 2017年10月25日(JDK1.8)
- 作者:
- ylyue
-
-
字段概要
字段 修饰符和类型 字段 说明 static java.lang.StringDATE_FORMATDate 格式化字符串static java.time.format.DateTimeFormatterDATE_FORMATTERDate 格式化static java.lang.StringDATE_TIME_FORMATDateTime 格式化字符串static java.time.format.DateTimeFormatterDATE_TIME_FORMATTERDateTime 格式化static java.time.format.DateTimeFormatterDATE_TIME_KEEP_MS_FORMATTERDateTime 保留毫秒格式化static java.time.format.DateTimeFormatterFORMATTER年-月-日T时:分:秒static java.time.format.DateTimeFormatterMONTH_START_FORMATTER当月起始时间static java.lang.StringTIME_FORMATTime 格式化字符串static java.time.format.DateTimeFormatterTIME_FORMATTERTime 格式化static java.time.format.DateTimeFormatterTODAY_END_FORMATTER当天结束时间static java.time.format.DateTimeFormatterTODAY_START_FORMATTER当天起始时间
-
构造器概要
构造器 构造器 说明 DateUtils()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static longdateDaysDifference(java.time.LocalDate startDate, java.time.LocalDate endDate)计算日期相差天数static longdateDaysDifference(java.time.LocalDateTime startTime, java.time.LocalDateTime endTime)计算日期相差天数static java.lang.StringgetDateFormatter()获得当前日期的标准字符串格式static java.lang.StringgetDatetimeFormatter()获得当前日期时间的标准字符串格式static java.lang.LonggetTimestamp()获得当前时间戳static java.lang.StringgetTodayEndFormatter()获得当天结束时间的标准字符串格式static java.lang.StringgetTodayStartFormatter()获得当天起始时间的标准字符串格式static java.lang.StringgetWeekmorningFormatter()获得本周开始时间的标准字符串格式static java.lang.StringgetWeeknight()获得本周日结束时间的标准字符串格式static booleanisBetween(java.lang.String startTime, java.lang.String dateTime, java.lang.String endTime)判断某个时间是否在某个时间段static booleanisBetween(java.time.LocalDateTime startTime, java.time.LocalDateTime dateTime, java.time.LocalDateTime endTime)判断某个时间是否在某个时间段static booleanisBetween(java.util.Date startTime, java.util.Date dateTime, java.util.Date endTime)判断某个时间是否在某个时间段static java.lang.Stringto_y_M_d_H_m_s(java.time.temporal.TemporalAccessor date)将TemporalAccessor类型进行标准日期时间字符串格式化static java.lang.StringtoDateFormatter(long timestamp)将毫秒时间(时间戳)转化为标准日期字符串格式static java.lang.StringtoDateFormatter(java.time.temporal.TemporalAccessor date)将TemporalAccessor类型进行标准日期字符串格式化static java.lang.StringtoDateFormatter(java.util.Date date)将Date类型进行标准日期字符串格式化static java.lang.StringtoDateTimeFormatter(long timestamp)将毫秒时间(时间戳)转化为标准日期时间字符串格式static java.lang.StringtoDateTimeFormatter(java.util.Date date)将Date类型进行标准日期时间字符串格式化static java.time.LocalDateTimetoLocalDateTime(java.util.Date date)将 Date 转 LocalDateTimestatic java.lang.LongtoTimestamp(java.lang.String dateTime)将日期时间转换成时间戳-
从类继承的方法 cn.hutool.core.date.DateUtil
age, ageOfNow, ageOfNow, beginOfDay, beginOfDay, beginOfMonth, beginOfMonth, beginOfQuarter, beginOfQuarter, beginOfSecond, beginOfSecond, beginOfWeek, beginOfWeek, beginOfWeek, beginOfYear, beginOfYear, between, between, betweenDay, betweenMonth, betweenMs, betweenWeek, betweenYear, calendar, calendar, calendar, ceiling, ceiling, compare, compare, createStopWatch, createStopWatch, current, currentSeconds, date, date, date, date, date, dateNew, dateSecond, dayOfMonth, dayOfWeek, dayOfWeekEnum, endOfDay, endOfDay, endOfMonth, endOfMonth, endOfQuarter, endOfQuarter, endOfSecond, endOfSecond, endOfWeek, endOfWeek, endOfWeek, endOfYear, endOfYear, format, format, format, format, format, formatBetween, formatBetween, formatBetween, formatBetween, formatChineseDate, formatDate, formatDateTime, formatHttpDate, formatLocalDateTime, formatTime, getBeginValue, getChineseZodiac, getEndValue, getZodiac, hour, isAM, isAM, isExpired, isExpired, isIn, isLeapYear, isPM, isSameDay, isSameDay, isSameTime, lastMonth, lastWeek, millsecond, minute, month, monthEnum, nanosToMillis, nanosToSeconds, nextMonth, nextWeek, now, offset, offsetDate, offsetDay, offsetHour, offsetMillisecond, offsetMinute, offsetMonth, offsetSecond, offsetWeek, parse, parse, parse, parse, parse, parse, parseCST, parseDate, parseDateTime, parseLocalDateTime, parseLocalDateTime, parseTime, parseTimeToday, parseUTC, quarter, quarterEnum, range, rangeToList, round, round, second, secondToTime, spendMs, spendNt, thisDayOfMonth, thisDayOfWeek, thisDayOfWeekEnum, thisHour, thisMillsecond, thisMinute, thisMonth, thisMonthEnum, thisSecond, thisWeekOfMonth, thisWeekOfYear, thisYear, timer, timer, timeToSecond, today, toInstant, toInstant, toInstant, toIntSecond, toLocalDateTime, toLocalDateTime, tomorrow, truncate, truncate, weekCount, weekOfMonth, weekOfYear, year, yearAndQuarter, yearAndQuarter, yearAndQuarter, yesterday
-
-
-
-
字段详细资料
-
DATE_TIME_FORMAT
public static final java.lang.String DATE_TIME_FORMAT
DateTime 格式化字符串年-月-日 时:分:秒(标准北京时间)
- 另请参阅:
- 常量字段值
-
DATE_FORMAT
public static final java.lang.String DATE_FORMAT
Date 格式化字符串年-月-日
- 另请参阅:
- 常量字段值
-
TIME_FORMAT
public static final java.lang.String TIME_FORMAT
Time 格式化字符串时:分:秒
- 另请参阅:
- 常量字段值
-
DATE_TIME_FORMATTER
public static final java.time.format.DateTimeFormatter DATE_TIME_FORMATTER
DateTime 格式化年-月-日 时:分:秒(标准北京时间)
-
DATE_FORMATTER
public static final java.time.format.DateTimeFormatter DATE_FORMATTER
Date 格式化年-月-日
-
TIME_FORMATTER
public static final java.time.format.DateTimeFormatter TIME_FORMATTER
Time 格式化时:分:秒
-
FORMATTER
public static final java.time.format.DateTimeFormatter FORMATTER
年-月-日T时:分:秒
-
DATE_TIME_KEEP_MS_FORMATTER
public static final java.time.format.DateTimeFormatter DATE_TIME_KEEP_MS_FORMATTER
DateTime 保留毫秒格式化年-月-日 时:分:秒:毫秒
-
TODAY_START_FORMATTER
public static final java.time.format.DateTimeFormatter TODAY_START_FORMATTER
当天起始时间年-月-日 00:00:00
-
TODAY_END_FORMATTER
public static final java.time.format.DateTimeFormatter TODAY_END_FORMATTER
当天结束时间年-月-日 23:59:59
-
MONTH_START_FORMATTER
public static final java.time.format.DateTimeFormatter MONTH_START_FORMATTER
当月起始时间年-月-01 00:00:00
-
-
方法详细资料
-
isBetween
public static boolean isBetween(java.lang.String startTime, java.lang.String dateTime, java.lang.String endTime)判断某个时间是否在某个时间段String 类型值应该是一个按照 yyyy-MM-dd HH:mm:ss 规则格式化后的字符串
若类型不确定请使用
isBetween(LocalDateTime, LocalDateTime, LocalDateTime)- 参数:
startTime- 起始时间dateTime- 比较时间endTime- 结束时间- 返回:
- 是否在…之间
-
isBetween
public static boolean isBetween(java.time.LocalDateTime startTime, java.time.LocalDateTime dateTime, java.time.LocalDateTime endTime)判断某个时间是否在某个时间段- 参数:
startTime- 起始时间dateTime- 比较时间endTime- 结束时间- 返回:
- 是否在…之间
-
isBetween
public static boolean isBetween(java.util.Date startTime, java.util.Date dateTime, java.util.Date endTime)判断某个时间是否在某个时间段- 参数:
startTime- 起始时间dateTime- 比较时间endTime- 结束时间- 返回:
- 是否在…之间
-
getTimestamp
public static java.lang.Long getTimestamp()
获得当前时间戳- 返回:
- 时间戳
-
getDateFormatter
public static java.lang.String getDateFormatter()
获得当前日期的标准字符串格式- 返回:
- 年-月-日
-
getDatetimeFormatter
public static java.lang.String getDatetimeFormatter()
获得当前日期时间的标准字符串格式- 返回:
- 年-月-日 时:分:秒(标准北京时间)
-
getTodayStartFormatter
public static java.lang.String getTodayStartFormatter()
获得当天起始时间的标准字符串格式- 返回:
- 年-月-日 00:00:00
-
getTodayEndFormatter
public static java.lang.String getTodayEndFormatter()
获得当天结束时间的标准字符串格式- 返回:
- 年-月-日 23:59:59
-
getWeekmorningFormatter
public static java.lang.String getWeekmorningFormatter()
获得本周开始时间的标准字符串格式- 返回:
- 年-月-日 00:00:00
-
getWeeknight
public static java.lang.String getWeeknight()
获得本周日结束时间的标准字符串格式- 返回:
- 年-月-日 23:59:59
-
toTimestamp
public static java.lang.Long toTimestamp(java.lang.String dateTime)
将日期时间转换成时间戳- 参数:
dateTime- 日期时间- 返回:
- 时间戳
-
toLocalDateTime
public static java.time.LocalDateTime toLocalDateTime(java.util.Date date)
将 Date 转 LocalDateTime默认使用系统时区转换
- 参数:
date- 日期- 返回:
- 本地日期时间
-
toDateFormatter
public static java.lang.String toDateFormatter(long timestamp)
将毫秒时间(时间戳)转化为标准日期字符串格式- 参数:
timestamp- 毫秒(时间戳)- 返回:
- 年-月-日
-
toDateFormatter
public static java.lang.String toDateFormatter(java.util.Date date)
将Date类型进行标准日期字符串格式化- 参数:
date- 日期- 返回:
- 年-月-日
-
toDateFormatter
public static java.lang.String toDateFormatter(java.time.temporal.TemporalAccessor date)
将TemporalAccessor类型进行标准日期字符串格式化- 参数:
date- 日期- 返回:
- 年-月-日
-
toDateTimeFormatter
public static java.lang.String toDateTimeFormatter(long timestamp)
将毫秒时间(时间戳)转化为标准日期时间字符串格式- 参数:
timestamp- 毫秒(时间戳)- 返回:
- 年-月-日 时:分:秒
-
toDateTimeFormatter
public static java.lang.String toDateTimeFormatter(java.util.Date date)
将Date类型进行标准日期时间字符串格式化- 参数:
date- 日期- 返回:
- 年-月-日 时:分:秒
-
to_y_M_d_H_m_s
public static java.lang.String to_y_M_d_H_m_s(java.time.temporal.TemporalAccessor date)
将TemporalAccessor类型进行标准日期时间字符串格式化- 参数:
date- 日期- 返回:
- 年-月-日 时:分:秒
-
dateDaysDifference
public static long dateDaysDifference(java.time.LocalDateTime startTime, java.time.LocalDateTime endTime)计算日期相差天数- 参数:
startTime- 开始时间endTime- 结束时间- 返回:
- 相差天数
-
dateDaysDifference
public static long dateDaysDifference(java.time.LocalDate startDate, java.time.LocalDate endDate)计算日期相差天数- 参数:
startDate- 开始日期endDate- 结束日期- 返回:
- 相差天数
-
-