public class DateUtils extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
DATE_PATTERN
时间格式(yyyy-MM-dd)
|
static String |
DATE_TIME_PATTERN
时间格式(yyyy-MM-dd HH:mm:ss)
|
| 构造器和说明 |
|---|
DateUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static int |
daysBetween(Date smdate,
Date bdate)
计算两个日期之间相差的天数
|
static String |
format(Date date)
转换日期为String使用默认的格式(yyyy-MM-dd)
|
static String |
format(Date date,
String pattern)
转换日期为String
|
static Long |
getCurrentUnixTime()
获取当前时间戳
|
static boolean |
isWeekend(Date d)
判断日期是否是周末
|
static boolean |
isWeekend(String d)
判断日期是否是周末
|
static boolean |
isWeekendByTimestamp(String timestamp)
判断日期是否是周末
|
static Date |
parse(String date)
将字符串转为日期
|
public static String format(Date date)
date - Datepublic static String format(Date date, String pattern)
date - Datepattern - 转换的格式public static Date parse(String date) throws Exception
date - 字符串Exceptionpublic static Long getCurrentUnixTime()
public static boolean isWeekend(Date d)
d - 日期public static boolean isWeekend(String d) throws Exception
d - yyyy-MM-ddExceptionpublic static boolean isWeekendByTimestamp(String timestamp) throws Exception
timestamp - 时间戳Exceptionpublic static int daysBetween(Date smdate, Date bdate) throws ParseException
smdate - 较小的时间bdate - 较大的时间ParseExceptionCopyright © 2017. All rights reserved.