public class CalendarUtil extends Object
| 限定符 | 构造器和说明 |
|---|---|
protected |
CalendarUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static int |
differentDays(Date date1,
Date date2)
求两个日期之间距离的天数
|
static Date |
getDate(Date date,
int days)
根据指定日期,向后或向前推算出对应的日期 比如:2019-2-15日 向后推7天或向前推7天 是哪天
|
static int |
getDayOfMonth(Date date)
获得指定日期在对应月的第几天(获得当前日)
|
static int |
getDayOfWeek(Date date,
boolean isChineseWeekend)
获得指定日期在对应周的第几天
|
static int |
getDayOfYear(Date date)
获得指定日期在对应年的第几天
|
static int |
getDaysOfMonth(int year,
int month)
获取此月最大天数
|
static int |
getDaysOfYear(int year)
获取此年的最大天数
|
static Date |
getQuarterTime(int month,
boolean isEnd)
指定月 获取该月份对应季度的开始日期或结束日期
|
static int |
getWeekOfMonth(Date date)
获得今天是这个月的第几周
|
static boolean |
isLeapYear(int year)
是否闰年
|
public static int differentDays(Date date1, Date date2)
date1 - 开始时间date2 - 结束时间public static int getDaysOfMonth(int year,
int month)
date - 日期public static int getDaysOfYear(int year)
year - public static boolean isLeapYear(int year)
year - 需要判断的年份public static Date getQuarterTime(int month, boolean isEnd)
year - 指定年month - 指定月isEnd - true将返回季度结束日期,false为季度开始时间public static Date getDate(Date date, int days)
date - 指定日期 如果为空默认当前时间days - 整数向未来日期计算 负数向过去日期计算public static int getWeekOfMonth(Date date)
date - 指定日期 如果为null 默认当前时间public static int getDayOfYear(Date date)
date - 指定日期 如果为null 默认当前时间public static int getDayOfMonth(Date date)
date - 指定日期 如果为null 默认当前时间public static int getDayOfWeek(Date date, boolean isChineseWeekend)
date - 指定日期 如果为null 默认当前时间isChineseWeekend - 在中国,周一是一周的开始,其他国家是周日为一周的开始Copyright © 2020. All rights reserved.