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