public class DateUtils extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static TimeZone |
DEFAULT_TIME_ZONE |
static String |
FORMAT_DATE |
static String |
FORMAT_DATE_MONTH |
static String |
FORMAT_DATE_YEAR |
static String |
FORMAT_DATETIME |
static String |
FORMAT_TIME |
static String |
FORMAT_TIME_HOUR |
static String |
FORMAT_TIME_MINUTE |
static String |
FORMAT_TIMESTAMP |
static String |
TIME_ZONE_GMT8 |
| 构造器和说明 |
|---|
DateUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static Date |
add(Date date,
int num,
int field)
时间加减
|
static Date |
addDay(Date date,
int num)
时间加减天数
|
static String |
date2string(Date date)
Format Date Time
|
static String |
datetime2string(Date date)
Format Date Time
|
static String |
format(Date date,
String format)
Format Date Time
|
static int |
getBetweenDays(Date start,
Date end)
日期间隔天数
|
static int |
getBetweenYears(Date start,
Date end)
日期间隔年数
|
static int |
getDateBetween(Date start,
Date end,
Integer calendarField)
日期间隔维度
|
static Date |
getOnlyDate(Date date)
获取时间戳(秒)
|
static String |
getTimestamp()
获取时间戳(精确到毫秒)
|
static Long |
getUnixTime(Date date)
获取时间戳(秒)
|
static boolean |
isSame(Date one,
Date two,
String format)
是否日期相同
|
static Date |
parse(String date,
String format)
解析日期
|
static Date |
string2date(String value)
String to Date
|
static String |
timeCountDown(Date endDate)
倒计时
|
public static final TimeZone DEFAULT_TIME_ZONE
public static String format(Date date, String format)
date - 日期format - 格式public static String datetime2string(Date date)
date - 日期public static Date add(Date date, int num, int field)
date - 开始日期num - 增加数field - 增加单位public static int getDateBetween(Date start, Date end, Integer calendarField)
start - 开始end - 结束calendarField - 维度public static int getBetweenDays(Date start, Date end)
start - 开始end - 结束public static int getBetweenYears(Date start, Date end)
start - 开始end - 结束public static boolean isSame(Date one, Date two, String format)
one - 日期1two - 日期2format - 格式public static String getTimestamp()
Copyright © 2024. All rights reserved.