public class DateUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
DATE_FORMAT |
static String |
DATETIME_FORMAT |
static String |
TIME_FORMAT |
| 构造器和说明 |
|---|
DateUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
equalsTimestamp(Timestamp o1,
Timestamp o2)
比较两个时间戳是否相等,仅比较年月日时分秒
|
static Calendar |
getCalendar(long timeInMills)
获取Calendar
|
static Calendar |
getCalendar(String sourceStr)
获取Calendar
|
static String |
getFormatTime(Calendar calendar,
String template)
获取格式化后的时间串
|
static String |
getFormatTime(Date date,
String template)
获取格式化后的时间串
|
static String |
getFormatTime(String template) |
static String |
getFormatTime(String sourceStr,
String template) |
static String |
getFormatTimeAgo(int days,
long timeInMillis,
String template)
3天前的时间常用格式
|
static Calendar |
getNewCalendar(long millis) |
static Date |
getNowDate(String format) |
static Date |
getNowSqlDate() |
static Timestamp |
getNowSqlTimestamp() |
static String |
getWeekdayChineseStrByDate(Date date)
返回日期的星期几的中文字符串,例如返回“星期三”
|
static int |
getWeekInt(Calendar calendar)
获取Week
|
static String |
getWeekString(Calendar calendar)
获取Week
|
static Date |
sqlDate2UtilDate(Date date) |
static Date |
sqlTimestamp2UtilDate(Timestamp date) |
static Date |
utilDate2SqlDate(Date date) |
static Timestamp |
utilDate2SqlTimestamp(Date date) |
public static Calendar getNewCalendar(long millis)
public static Date getNowSqlDate()
public static Timestamp getNowSqlTimestamp()
public static String getWeekdayChineseStrByDate(Date date)
date,需要处理的日期 - public static boolean equalsTimestamp(Timestamp o1, Timestamp o2)
o1,比较时间1 - o2,比较时间2 - public static String getFormatTime(Date date, String template)
date - datetemplate - the pattern, such as "yyyyMMddHHmmss"public static String getFormatTime(Calendar calendar, String template)
calendar - calendartemplate - the pattern, such as "yyyyMMddHHmmss"public static Calendar getCalendar(String sourceStr)
sourceStr - the sourceStr, such as "20151024102424",the length must is 14public static Calendar getCalendar(long timeInMills)
timeInMills - public static String getFormatTimeAgo(int days, long timeInMillis, String template)
timeInMillis - template - public static int getWeekInt(Calendar calendar)
calendar - calendarCopyright © 2023. All rights reserved.