public class DateUtil extends Object
| 构造器和说明 |
|---|
DateUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static Date |
beginOfDay(Date date)
获取指定时间的当天开始时间
|
static Date |
beginOfMonth(Date date)
获取指定时间的当月开始时间
|
static Date |
beginOfYear(Date date)
获取指定时间的当年开始时间
|
static long |
between(Date startDate,
Date endDate,
int dateFiled) |
static int |
compare(Date date1,
Date date2) |
static Date |
date()
获取当前时间
|
static Date |
date(long timestamp)
获取指定时间戳的时间
|
static int |
day(Date date)
获取指定时间的日
|
static Date |
endOfDay(Date date)
获取指定时间的当天结束时间
|
static Date |
endOfMonth(Date date)
获取指定时间的当月结束时间
|
static Date |
endOfYear(Date date)
获取指定时间的当年结束时间
|
static Date |
lastMonth()
上个月
|
static Date |
lastWeek()
上周
|
static int |
month(Date date)
获取指定时间的月,并非以0开始的月
|
static Date |
nextMonth()
下个月
|
static Date |
nextWeek()
下周
|
static Date |
now()
获取当前时间
|
static Date |
offset(Date date,
int dateField,
int amount)
增减日期
|
static Date |
toDate(String dateStr)
字符串转为时间
|
static Date |
toDate(String dateStr,
String format)
字符串转为时间
|
static Date |
tomorrow()
明天
|
static String |
toString(Date date)
时间转为字符串
|
static String |
toString(Date date,
String format)
时间转为字符串
|
static int |
year(Date date)
获取指定时间的年
|
static Date |
yesterday()
昨天
|
public static Date now()
public static Date date()
public static Date date(long timestamp)
public static Date toDate(String dateStr, String format)
dateStr - 时间字符川format - 转换格式public static String toString(Date date, String format)
date - 时间format - 格式public static int year(Date date)
date - 指定时间public static int month(Date date)
date - 指定时间public static int day(Date date)
date - 指定时间public static Date yesterday()
public static Date tomorrow()
public static Date lastWeek()
public static Date nextWeek()
public static Date lastMonth()
public static Date nextMonth()
public static Date offset(Date date, int dateField, int amount)
date - 目标日期dateField - 字段amount - 数量Copyright © 2022. All rights reserved.