public class DateUtils extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
DATE_PATTERN |
static String |
DATETIME_PATTERN |
static String |
MILLS_PATTERN |
static String |
MONTH_PATTERN |
static String |
YEAR_PATTERN |
| 构造器和说明 |
|---|
DateUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static Date |
addDays(Date date,
int days)
days 天以后
|
static Date |
addHours(Date date,
int hours)
hours 小时以后
|
static Date |
addMinutes(Date date,
int minutes)
minutes 分钟以后
|
static Date |
addMonths(Date date,
int months)
months 月以后
|
static Date |
addSeconds(Date date,
int seconds)
seconds 秒以后
|
static Date |
addYears(Date date,
int years)
years 年以后
|
static Date |
dateAdd(Date date,
int years,
int months,
int days)
日期增加
|
static Date |
dateCeil(Date date)
日期向上取整(下一天刚开始)
|
static Date |
dateFloor(Date date)
日期向下取整(当天刚开始)
|
static int |
dayOfMonth(Date date)
当天在当月中所处的天数
|
static int |
dayOfWeek(Date date)
获取星期
|
static int |
dayOfYear(Date date)
当天在当年中所处的天数
|
static int |
daysOfMonth(Date month)
获取某月的天数
|
static int |
daysOfMonth(String month)
获取某月的天数
|
static int |
daysOfYear(Date year)
获取某年的天数
|
static int |
daysOfYear(String year)
获取某年的天数
|
static String |
format(Date date,
String pattern)
格式化日期
|
static String |
formatDate(Date date)
按 yyyy-MM-dd 格式化日期
|
static String |
formatDateTime(Date date)
按 yyyy-MM-dd HH:mm 格式化日期
|
static String |
formatMills(Date date)
按 yyyyMMddHHmmssSSS 格式化日期
|
static String |
formatMonth(Date date)
按 yyyy-MM 格式化日期
|
static String |
formatYear(Date date)
按 yyyy 格式化日期
|
static boolean |
isMonthBeginning(Date date)
是否是月初
|
static boolean |
isMonthEnding(Date date)
是否是月底
|
static boolean |
isYearBeginning(Date date)
是否是年初
|
static boolean |
isYearEnding(Date date)
是否是年底
|
static Date |
max(Date... dates)
最大日期
|
static Date |
min(Date... dates)
最小日期
|
static int |
monthOf(Date date)
获取当时的月份
|
static Date |
nextDay(Date date)
下一天
|
static Date |
parse(String date,
String pattern)
解析日期
|
static Date |
parseDate(String date)
按 yyyy-MM-dd 解析日期
|
static Date |
parseDateTime(String date)
按 yyyy-MM-dd HH:mm 解析日期
|
static Date |
parseMills(String date)
按 yyyyMMddHHmmssSSS 解析日期
|
static Date |
parseMonth(String date)
按 yyyy-MM 解析日期
|
static Date |
parseYear(String date)
按 yyyy 解析日期
|
static Date |
prevDay(Date date)
前一天
|
static Date |
timeAdd(Date date,
int hours,
int minutes,
int seconds,
int millis)
日期增加
|
static Date |
todayBeginning()
获取今天刚开始的时刻
|
static int |
weekOfMonth(Date date)
获取某一月中的周数
|
static int |
weekOfYear(Date date)
获取一年中的周数
|
static int |
yearOf(Date date)
获取当时的年数
|
public static Date dateAdd(Date date, int years, int months, int days)
date - 被增加日期years - 增加的年数months - 增加的月数days - 增加的天数public static Date timeAdd(Date date, int hours, int minutes, int seconds, int millis)
date - 被增加日期hours - 添加的小时数minutes - 添加的分钟数seconds - 添加的秒数millis - 添加的毫秒数public static int daysOfMonth(String month)
month - 月份(yyyy-MM)public static int daysOfMonth(Date month)
month - 月份public static int daysOfYear(String year)
year - 年(yyyy)public static int daysOfYear(Date year)
year - 年public static Date todayBeginning()
public static boolean isMonthBeginning(Date date)
public static boolean isMonthEnding(Date date)
public static boolean isYearBeginning(Date date)
public static boolean isYearEnding(Date date)
public static int yearOf(Date date)
public static int monthOf(Date date)
public static int dayOfYear(Date date)
public static int dayOfMonth(Date date)
public static int dayOfWeek(Date date)
Calendar.SUNDAY,
Calendar.MONDAY,
Calendar.TUESDAY,
Calendar.WEDNESDAY,
Calendar.THURSDAY,
Calendar.FRIDAY,
Calendar.SATURDAYpublic static int weekOfYear(Date date)
public static int weekOfMonth(Date date)
Copyright © 2024. All rights reserved.