public class DateUtils
extends cn.hutool.core.date.DateUtil
Modifier and Type | Field and Description |
---|---|
static String |
DATE_FORMAT
Date 格式化字符串
|
static DateTimeFormatter |
DATE_FORMATTER
Date 格式化
|
static String |
DATE_TIME_FORMAT
DateTime 格式化字符串
|
static DateTimeFormatter |
DATE_TIME_FORMATTER
DateTime 格式化
|
static DateTimeFormatter |
DATE_TIME_KEEP_MS_FORMATTER
DateTime 保留毫秒格式化
|
static DateTimeFormatter |
FORMATTER
年-月-日T时:分:秒
|
static DateTimeFormatter |
MONTH_START_FORMATTER
当月起始时间
|
static String |
TIME_FORMAT
Time 格式化字符串
|
static DateTimeFormatter |
TIME_FORMATTER
Time 格式化
|
static DateTimeFormatter |
TODAY_END_FORMATTER
当天结束时间
|
static DateTimeFormatter |
TODAY_START_FORMATTER
当天起始时间
|
Constructor and Description |
---|
DateUtils() |
Modifier and Type | Method and Description |
---|---|
static long |
dateDaysDifference(LocalDate startDate,
LocalDate endDate)
计算日期相差天数
|
static long |
dateDaysDifference(LocalDateTime startTime,
LocalDateTime endTime)
计算日期相差天数
|
static String |
getDateFormatter()
获得当前日期的标准字符串格式
|
static String |
getDatetimeFormatter()
获得当前日期时间的标准字符串格式
|
static long |
getTimestamp()
获得当前时间戳
|
static long |
getTimestamp(int offsetMillis)
获得当前时间偏移后的时间戳
|
static String |
getTodayEndFormatter()
获得当天结束时间的标准字符串格式
|
static String |
getTodayStartFormatter()
获得当天起始时间的标准字符串格式
|
static String |
getWeekmorningFormatter()
获得本周开始时间的标准字符串格式
|
static String |
getWeeknight()
获得本周日结束时间的标准字符串格式
|
static boolean |
isBetween(Date startTime,
Date dateTime,
Date endTime)
判断某个时间是否在某个时间段
|
static boolean |
isBetween(LocalDateTime startTime,
LocalDateTime dateTime,
LocalDateTime endTime)
判断某个时间是否在某个时间段
|
static boolean |
isBetween(String startTime,
String dateTime,
String endTime)
判断某个时间是否在某个时间段
|
static String |
to_y_M_d_H_m_s(TemporalAccessor date)
Deprecated.
|
static String |
toDateFormatter(Date date)
将
Date 类型进行标准日期字符串格式化 |
static String |
toDateFormatter(long timestamp)
将毫秒时间(时间戳)转化为标准日期字符串格式
|
static String |
toDateFormatter(TemporalAccessor date)
将
TemporalAccessor 类型进行标准日期字符串格式化 |
static String |
toDateTimeFormatter(Date date)
将
Date 类型进行标准日期时间字符串格式化 |
static String |
toDateTimeFormatter(long timestamp)
将毫秒时间(时间戳)转化为标准日期时间字符串格式
|
static String |
toDateTimeFormatter(TemporalAccessor date)
将
TemporalAccessor 类型进行标准日期时间字符串格式化 |
static LocalDateTime |
toLocalDateTime(Date date)
将 Date 转 LocalDateTime
|
static Long |
toTimestamp(String dateTime)
将日期时间转换成时间戳
|
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
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
public static final String DATE_TIME_FORMAT
年-月-日 时:分:秒(标准北京时间)
public static final String DATE_FORMAT
年-月-日
public static final String TIME_FORMAT
时:分:秒
public static final DateTimeFormatter DATE_TIME_FORMATTER
年-月-日 时:分:秒(标准北京时间)
public static final DateTimeFormatter DATE_FORMATTER
年-月-日
public static final DateTimeFormatter TIME_FORMATTER
时:分:秒
public static final DateTimeFormatter FORMATTER
public static final DateTimeFormatter DATE_TIME_KEEP_MS_FORMATTER
年-月-日 时:分:秒:毫秒
public static final DateTimeFormatter TODAY_START_FORMATTER
年-月-日 00:00:00
public static final DateTimeFormatter TODAY_END_FORMATTER
年-月-日 23:59:59
public static final DateTimeFormatter MONTH_START_FORMATTER
年-月-01 00:00:00
public static boolean isBetween(String startTime, String dateTime, String endTime)
String 类型值应该是一个按照 yyyy-MM-dd HH:mm:ss 规则格式化后的字符串
若类型不确定请使用 isBetween(LocalDateTime, LocalDateTime, LocalDateTime)
startTime
- 起始时间dateTime
- 比较时间endTime
- 结束时间public static boolean isBetween(LocalDateTime startTime, LocalDateTime dateTime, LocalDateTime endTime)
startTime
- 起始时间dateTime
- 比较时间endTime
- 结束时间public static boolean isBetween(Date startTime, Date dateTime, Date endTime)
startTime
- 起始时间dateTime
- 比较时间endTime
- 结束时间public static long getTimestamp()
public static long getTimestamp(int offsetMillis)
offsetMillis
- 偏移毫秒public static String getDateFormatter()
public static String getDatetimeFormatter()
public static String getTodayStartFormatter()
public static String getTodayEndFormatter()
public static String getWeekmorningFormatter()
public static String getWeeknight()
public static Long toTimestamp(String dateTime)
dateTime
- 日期时间public static LocalDateTime toLocalDateTime(Date date)
date
- 日期public static String toDateFormatter(long timestamp)
timestamp
- 毫秒(时间戳)public static String toDateFormatter(Date date)
Date
类型进行标准日期字符串格式化date
- 日期public static String toDateFormatter(TemporalAccessor date)
TemporalAccessor
类型进行标准日期字符串格式化date
- 日期public static String toDateTimeFormatter(long timestamp)
timestamp
- 毫秒(时间戳)public static String toDateTimeFormatter(Date date)
Date
类型进行标准日期时间字符串格式化date
- 日期public static String toDateTimeFormatter(TemporalAccessor date)
TemporalAccessor
类型进行标准日期时间字符串格式化date
- 日期@Deprecated public static String to_y_M_d_H_m_s(TemporalAccessor date)
toDateTimeFormatter(TemporalAccessor)
TemporalAccessor
类型进行标准日期时间字符串格式化date
- 日期public static long dateDaysDifference(LocalDateTime startTime, LocalDateTime endTime)
startTime
- 开始时间endTime
- 结束时间Copyright © 2022 Pivotal Software, Inc.. All rights reserved.