Package tech.mgl.core.utils
Class MGL_TimeUtils
java.lang.Object
tech.mgl.core.utils.MGL_TimeUtils
时间工具类
- Author:
- bo
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longdifferentDays(String start, String end) 获得两个日期之间的间隔 单位 天static longdifferentHours(String start, String end) 获得两个日期之间的时间间隔 单位 小时static String以默认格式格式化当前日期static String格式化日期static DategetAppointDayCurrentTime(Date date, Integer days) 同上 获取指定日期的当前时间static DategetAppointDayOfEndTime(Date date, Integer days) mysql保存系统传递的时间会诡异的增加一秒钟 MySQL数据库对于毫秒大于500(验证版本5.7.11-log 其他会进位的版本没有进行验证)的数据进行进位 此方法可以解决此问题 获取指定日期的 23:59:59 时间 0 为今天static String获取当前时间 默认格式为:yyyy-MM-dd HH:mm:ssstatic StringgetCurrentTime(String pattern) 获取当前时间 默认格式为:yyyy-MM-dd HH:mm:ssstatic DategetDate(int value) static DategetDateAfter(Date d, int day) 获取day天后的日期static DategetDateBefore(Date d, int day) 得到day天前的时间static StringgetDay(int value) static String获取上或者下个日期 1就是明天 -1 昨天的日期static intstatic Stringstatic StringgetDayOfWeekDisplayName(Locale locale) static LocalDatestatic StringgetFirstDayOfMonth(Integer month) static LocalDategetFirstDayOfMonth(Integer year, Integer month) static intstatic Stringstatic StringgetHourOfDayDisplayName(Locale locale) static LocalDatestatic StringgetLastDayOfMonth(int month) static LocalDategetLastDayOfMonth(Integer year, Integer month) static LocalDateTimestatic StringgetMonth(int value) static String获取某个月static int返回当前月数字类型static intgetNumber(int type) 获取当前指定的类型的数字日期 如果 Calendar.YEAR 久返回数字的 2019static intgetQuarter(int month) 获取月份所在的季度static StringgetRunTime(long startTime) static StringgetShowFormatMS(Long ms) 毫秒转换成有格式的字符串,如:如:2000毫秒 就显示 00:00:02static StringgetShowFormatMS(Long ms, String symbol, boolean showMs) 毫秒转换成有格式的字符串,如:如:2000毫秒 就显示 00:00:02static DategetTime(int calendarVal, int value) 获取时间 以当前时间为准static Date获取时间static int获取当前日期在当前月是第几周static StringgetYear(int value) 获取年 value 为获取那年 如 下一年就是 1 上一年就是 -1static voidstatic LocalDatestatic LocalDateTimeparseDateTime(String dataTimeStr, String format) static Datestatic Date
-
Field Details
-
YYYY
- See Also:
-
YYYY_MM
- See Also:
-
YYYY_MM_DD
- See Also:
-
YYYYMMDDHHMMSS
- See Also:
-
YYYYMMDDHHMM
- See Also:
-
YYYY_MM_DD_HH_MM_SS
- See Also:
-
-
Constructor Details
-
MGL_TimeUtils
public MGL_TimeUtils()
-
-
Method Details
-
getCurrentTime
获取当前时间 默认格式为:yyyy-MM-dd HH:mm:ss- Parameters:
pattern- 日期格式- Returns:
-
getCurrentTime
获取当前时间 默认格式为:yyyy-MM-dd HH:mm:ss- Returns:
-
getShowFormatMS
毫秒转换成有格式的字符串,如:如:2000毫秒 就显示 00:00:02- Parameters:
ms- 要转换显示的毫秒时间- Returns:
- 返回格式 00:00:02
-
getShowFormatMS
毫秒转换成有格式的字符串,如:如:2000毫秒 就显示 00:00:02- Parameters:
ms- 要转换显示的毫秒时间- Returns:
- 返回格式 00:00:02
-
main
-
getDateAfter
获取day天后的日期- Parameters:
d-day-- Returns:
-
getDateBefore
得到day天前的时间- Parameters:
d-day- 单位为天- Returns:
-
getTime
获取时间- Parameters:
d-calendarVal- Calendar下的参数value- 具体的值- Returns:
-
parseDate
-
parseDateTime
-
getMonth
获取某个月- Parameters:
value-- Returns:
-
getMonth
-
getQuarter
public static int getQuarter(int month) 获取月份所在的季度- Parameters:
month-
-
getNumber
public static int getNumber(int type) 获取当前指定的类型的数字日期 如果 Calendar.YEAR 久返回数字的 2019- Parameters:
type-- Returns:
-
getMonthNumber
public static int getMonthNumber()返回当前月数字类型- Returns:
-
getYear
获取年 value 为获取那年 如 下一年就是 1 上一年就是 -1- Parameters:
value-- Returns:
-
getDay
获取上或者下个日期 1就是明天 -1 昨天的日期- Parameters:
value-- Returns:
-
getDay
-
getDate
-
getLastDayOfMonth
-
getLastDayOfMonth
-
getLastDayOfMonth
-
getFirstDayOfMonth
-
getFirstDayOfMonth
-
getFirstDayOfMonth
-
getWeekOfMonth
public static int getWeekOfMonth()获取当前日期在当前月是第几周- Returns:
-
getLocalTime
-
getDayOfWeek
public static int getDayOfWeek() -
getHourOfDay
public static int getHourOfDay() -
getHourOfDayDisplayName
-
getHourOfDayDisplayName
-
getDayOfWeekDisplayName
-
getDayOfWeekDisplayName
-
format
格式化日期- Parameters:
time-pattern-- Returns:
-
format
以默认格式格式化当前日期- Parameters:
time-- Returns:
-
getTime
获取时间 以当前时间为准- Parameters:
calendarVal-value-- Returns:
-
differentDays
获得两个日期之间的间隔 单位 天- Parameters:
start-end-- Returns:
- 参数
-
differentHours
获得两个日期之间的时间间隔 单位 小时- Parameters:
start-end-- Returns:
- 参数
-
strToDate
- Parameters:
strDate-- Returns:
- 参数
-
strToDate
- Parameters:
strDate-pattern-- Returns:
- 参数
-
getAppointDayOfEndTime
mysql保存系统传递的时间会诡异的增加一秒钟 MySQL数据库对于毫秒大于500(验证版本5.7.11-log 其他会进位的版本没有进行验证)的数据进行进位 此方法可以解决此问题 获取指定日期的 23:59:59 时间 0 为今天- Parameters:
date-days-- Returns:
-
getAppointDayCurrentTime
同上 获取指定日期的当前时间- Parameters:
date-days-- Returns:
-
getRunTime
-