类 DateUtil
java.lang.Object
cn.vonce.sql.uitls.DateUtil
时间工具类 Created by jovi on 2017/7/10.
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static java.time.LocalDatedateToLocalDate(Date date) date 转成 LocalDatestatic java.time.LocalDateTimedateToLocalDateTime(Date date) date 转成 LocalDateTimestatic java.time.LocalTimedateToLocalTime(Date date) date 转成 LocalTimestatic StringdateToString(Date date) 时间格式化为字符串static StringdateToString(Date date, String format) 时间格式化为字符串static intdifferentDays(Date date1, Date date2) 计算两个时间的差的天数getCalendarTable(Integer index) 获取日历表static StringgetInterval(String createTime) 获取时间间隔(用于显示动态)static StringgetInterval(Date date) 获取时间间隔(用于显示动态)获取前一个月的第一天的时间static List<java.time.LocalDate>getMiddleAllDate(java.time.LocalDate begin, java.time.LocalDate end) static Date获取当前时间的这个周的周一static Date获取指定时间的这个周的周一static Integer获取后一个月的第一天的时间static StringgetYesterdayByFormat(Integer offSet, String timeFormat) 获取前几天或者后几天的时间static DatelocalDateTimeToDate(java.time.LocalDateTime localDateTime) LocalDateTime 转成 Datestatic DatelocalDateToDate(java.time.LocalDate localDate) localDate 转成 Datestatic DatelocalTimeToDate(java.time.LocalTime localTime, java.time.LocalDate localDate) LocalTime 转成 Datestatic DatestringToDate(String createTime) 将字符串日期转为日期对象(默认格式:yyyy-MM-dd HH:mm:ss)static DatestringToDate(String createTime, String format) 将字符串日期转为日期对象static java.time.LocalDateTimestrTimeToLocalDateTime(String dateTime) 将字符串 转成 LocalDateTime 示例:"2016-04-04 11:50:53"static java.time.LocalDateTimestrTimeToLocalDateTime(String dateTime, java.time.format.DateTimeFormatter dateTimeFormatter) 将字符串 转成 LocalDateTime 示例:"2016-04-04 11:50:53"static StringunifyDateToString(Object date) 日期转字符串 支持Jdk8之前日期及Jdk8+的日期static StringunifyDateToString(Object date, String format) 日期转字符串 支持Jdk8之前日期及Jdk8+的日期static LongunifyDateToTimestamp(Object date) 日期转时间戳 支持Jdk8之前日期及Jdk8+的日期
-
构造器详细资料
-
DateUtil
public DateUtil()
-
-
方法详细资料
-
getInterval
获取时间间隔(用于显示动态)- 参数:
createTime-- 返回:
-
getInterval
获取时间间隔(用于显示动态)- 参数:
date-- 返回:
-
dateToString
时间格式化为字符串- 参数:
date-- 返回:
-
dateToString
时间格式化为字符串- 参数:
date-format-- 返回:
-
stringToDate
将字符串日期转为日期对象(默认格式:yyyy-MM-dd HH:mm:ss)- 参数:
createTime-- 返回:
-
stringToDate
将字符串日期转为日期对象- 参数:
createTime-format-- 返回:
-
differentDays
计算两个时间的差的天数- 参数:
date1- 时间较小的日期date2- 时间较大的日期- 返回:
-
strTimeToLocalDateTime
将字符串 转成 LocalDateTime 示例:"2016-04-04 11:50:53"- 参数:
dateTime- 时间- 返回:
- LocalDateTime
-
strTimeToLocalDateTime
public static java.time.LocalDateTime strTimeToLocalDateTime(String dateTime, java.time.format.DateTimeFormatter dateTimeFormatter) 将字符串 转成 LocalDateTime 示例:"2016-04-04 11:50:53"- 参数:
dateTime- 时间dateTimeFormatter- 格式化- 返回:
- LocalDateTime
-
dateToLocalDateTime
date 转成 LocalDateTime- 参数:
date- 日期
-
dateToLocalDate
date 转成 LocalDate- 参数:
date- 日期
-
dateToLocalTime
date 转成 LocalTime- 参数:
date- 日期
-
localDateTimeToDate
LocalDateTime 转成 Date- 参数:
localDateTime- 时间- 返回:
- 结果集
-
localDateToDate
localDate 转成 Date- 参数:
localDate- 结果集
-
localTimeToDate
LocalTime 转成 Date- 参数:
localTime- 本地时间localDate- 时间
-
unifyDateToString
日期转字符串 支持Jdk8之前日期及Jdk8+的日期- 参数:
date-- 返回:
-
unifyDateToString
日期转字符串 支持Jdk8之前日期及Jdk8+的日期- 参数:
date-format-- 返回:
-
unifyDateToTimestamp
日期转时间戳 支持Jdk8之前日期及Jdk8+的日期- 参数:
date-- 返回:
-
getLastMonthEndDay
获取前一个月的第一天的时间- 返回:
- 几号
-
getNextMonthEndDay
获取后一个月的第一天的时间- 返回:
- 几号
-
getCalendarTable
获取日历表- 参数:
index- -1表示上月 0表示当月 1表示下月- 返回:
- 结果集
-
getMiddleAllDate
public static List<java.time.LocalDate> getMiddleAllDate(java.time.LocalDate begin, java.time.LocalDate end) - 参数:
begin- 开始日期end- 结束日期- 返回:
- 开始与结束之间的所以日期,包括起止
-
getYesterdayByFormat
获取前几天或者后几天的时间- 参数:
offSet- 负数代表前几天timeFormat- 时间格式化类型- 返回:
- 格式化后的结果
-
getMonday
获取当前时间的这个周的周一- 返回:
-
getMonday
获取指定时间的这个周的周一- 参数:
date-- 返回:
-