public final class DateUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
DATE_FORMAT
日期格式化
|
static String |
DATE_TIME_FORMAT
简单的日期时间格式化
|
static String |
PURE_DATE_FORMAT
纯净日期格式化
|
static String |
PURE_TIME_FORMAT
纯净时间格式化
|
static String |
TIME_FORMAT
时间格式化
|
static String |
TIMESTAMP_FORMAT_15
时间戳格式化(15 位长度)
备注:因为 2019 最前面两位,在自己的有生之年,基本是不变的。
|
static String |
TIMESTAMP_FORMAT_17
时间戳格式化
17位长度
|
| 限定符和类型 | 方法和说明 |
|---|---|
static long |
convertMsToNs(long ms)
毫秒转化为纳秒
1.
|
static long |
costTimeInMills(Date start,
Date end)
计算消耗的毫秒
|
static String |
getCurrentDateStr()
获取日期当前字符串形式
|
static String |
getCurrentDateTimeStr()
获取当前日期时间字符串
|
static String |
getCurrentTimeMills()
当前的毫秒数
|
static String |
getCurrentTimeStampStr()
获取当前时间戳。
|
static String |
getCurrentTimeStampStr15()
获取当前时间戳。
|
static String |
getDateFormat(Date date,
String format)
获取格式化的日期
|
static Date |
getFormatDate(String dateStr,
String format)
对字符串格式化为日期
|
static Date |
now()
返回当前时间
|
static void |
sleep(long pauseMills)
当前线程主动沉睡
|
static void |
sleep(TimeUnit unit,
long timeout)
当前线程主动沉睡
|
public static String getDateFormat(Date date, String format)
date - 日期format - 格式化public static Date getFormatDate(String dateStr, String format)
dateStr - 日期字符串format - 格式化public static String getCurrentDateStr()
public static String getCurrentTimeStampStr()
public static String getCurrentTimeStampStr15()
public static String getCurrentTimeMills()
public static String getCurrentDateTimeStr()
public static long convertMsToNs(long ms)
ms - 毫秒public static Date now()
public static long costTimeInMills(Date start, Date end)
start - 开始时间end - 结束时间public static void sleep(long pauseMills)
pauseMills - 暂定的毫秒数public static void sleep(TimeUnit unit, long timeout)
unit - 时间单位timeout - 超时时间Copyright © 2020. All rights reserved.