public class TimeUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
DATE_YYYY_MM_SS |
| 构造器和说明 |
|---|
TimeUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
afterDays(String time)
判断 指定时间是否超过当前时间
|
static boolean |
belongCalendar(Date time,
Date from,
Date to)
判断time是否在from,to之内
|
static boolean |
belongCalendar(String time,
String from,
String to)
判断time是否在from,to之内
|
static long |
dateToLong(Date date)
date类型转换为long类型
|
static String |
dateToString(Date data,
String formatType)
date类型转换为String类型时间
|
static Long |
daysBetweenDay(Date first,
Date second)
计算两个日期之间相差的天、时、分、秒
|
static String |
formatThisTimeByMatch(String match)
根据格式返回当前时间
|
static String |
getNowDate()
根据格式返回当前时间 yyyy-MM-dd HH:mm:ss
|
static String |
getPreDays(Integer days)
获取某个时间后某天的时间(当前时间)
|
static String |
getPreDaysByDay(String timeStr,
Integer days)
获取某个时间后某天的时间(指定时间)
|
static String |
getPreMonth(Integer count)
描述:获取下几个月.当前时间开始
|
static String |
getPreMonthByDate(String time,
Integer count)
描述:获取某个时间的下几个月.
|
static Integer |
getTwoTimeDays(String startTime,
String endTime)
获得2个时间段的 相隔天数
|
static Date |
longToDate(long currentTime,
String formatType)
将时间戳转为 date类型
|
static String |
longToString(long currentTime,
String formatType)
将时间戳转换为String类型时间
|
static Date |
stringToDate(String strTime,
String formatType)
将string时间转为Date
|
static long |
stringToLong(String strTime,
String formatType)
将String类型时间转为时间戳
|
static String |
transForDate(Long ms)
时间戳转日期
|
static String |
transForDate(Long ms,
String format)
时间戳转日期(指定返回时间格式)
|
public static String DATE_YYYY_MM_SS
public static String getNowDate()
public static boolean belongCalendar(Date time, Date from, Date to)
time - 指定日期from - 开始日期to - 结束日期public static boolean belongCalendar(String time, String from, String to) throws ParseException
time - 指定日期from - 开始日期to - 结束日期ParseExceptionpublic static String getPreMonth(Integer count)
count - 月public static String getPreMonthByDate(String time, Integer count) throws ParseException
time - 指定的时间count - 月数ParseExceptionpublic static String getPreDays(Integer days)
days - 天数public static String getPreDaysByDay(String timeStr, Integer days) throws ParseException
timeStr - 指定时间days - 天数ParseException - 时间转换异常public static boolean afterDays(String time) throws ParseException
time - 指定的时间ParseExceptionpublic static Integer getTwoTimeDays(String startTime, String endTime) throws ParseException
startTime - 开始时间endTime - 结束时间ParseException - 时间转换异常public static String transForDate(Long ms, String format)
ms - 时间戳format - 指定返回时间格式public static Long daysBetweenDay(Date first, Date second) throws ParseException
first - 开始时间second - 结束时间ParseException - 转换异常public static String formatThisTimeByMatch(String match)
match - 格式 如 yyyy-MM-dd HH:mm:sspublic static String dateToString(Date data, String formatType)
data - 转换的时间formatType - 时间格式public static String longToString(long currentTime, String formatType) throws ParseException
currentTime - 时间戳formatType - 时间格式ParseException - 转换异常public static Date stringToDate(String strTime, String formatType) throws ParseException
strTime - 转换的时间 格式必须要与formatType的时间格式相同formatType - 格式ParseException - 转换异常public static Date longToDate(long currentTime, String formatType) throws ParseException
currentTime - e要转换的long类型的时间戳formatType - 格式ParseException - 转换异常public static long stringToLong(String strTime, String formatType) throws ParseException
strTime - String类型时间formatType - String类型时间格式ParseException - 转换异常public static long dateToLong(Date date)
date - 要转换的时间Copyright © 2019. All rights reserved.