public final class DateUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
DATE_FORMAT
default date format pattern
|
static String |
DATE_TIME_FORMAT |
static String |
FULL_DATE_TIME_FORMAT |
static String |
LOCATE_DATE_FORMAT |
static String |
MONTH_DATE_FORMAT |
static String |
MONTH_DAY_HOUR_MINUTE_FORMAT |
static String |
TIME_FORMAT |
static String |
YEAR_MONTH_FORMAT |
static String |
YEAR_MONTH_FORMAT_SHORT |
static String |
YEAR_WEEK_FORMAT |
static String |
YEAR_WEEK_FORMAT_SHORT |
| 限定符和类型 | 方法和说明 |
|---|---|
static Date |
addDate(Date date,
int number)
add day to the date
|
static Date |
addHour(Date date,
int v)
获取增加小时后的 Date
|
static Date |
addMinutes(Date date,
int number) |
static Date |
addMonth(Date date,
int number) |
static Date |
addSecond(Date date,
int number) |
static Date |
addWeek(Date date,
int v)
+周
|
static Date |
addYear(Date date,
int number) |
static boolean |
before(Date beginDate,
Date endDate) |
static boolean |
betweenHour(Date date,
int hour) |
static boolean |
betweenMinute(Date date,
int minute) |
static boolean |
betweenSecond(Date date,
int second) |
static Date |
clearTime(Date date)
清空日期的时间
|
static String |
formatDate(Date date)
format date with the default pattern
|
static String |
formatDate(Date date,
String pattern)
format date with the given pattern
|
static String |
formatTime(Date date) |
static Calendar |
getCalendarFromDate(Date date)
get calendar from date
|
static Date |
getCurrentDate() |
static String |
getCurrentDateFormat()
get current date
|
static String |
getCurrentDateStr() |
static String |
getCurrentDateTime() |
static String |
getCurrentTimeFormat() |
static String |
getCurrentWeekDay(Date date,
int day)
本周指定星期几的日期
|
static int |
getDateNum(Date fromDate,
Date endDate)
get number of days between the two given date
|
static List<String> |
getDateRange(String strBeginDate,
String strEndDate,
String pattern) |
static int |
getDayOfMonth(Date date) |
static int |
getDayOfWeek(Date date)
获取指定日期是一周的第几天,星期日是第一天
|
static Calendar |
getDefaultCalendar()
get the default calendar
|
static Date |
getDefaultDate() |
static List<String> |
getFullYear() |
static int |
getHour(Date now) |
static String |
getInterval(Date startDate,
Date endDate) |
static String |
getInterval(long intervalTime) |
static float |
getIntervalHour(Date startDate,
Date endDate) |
static int |
getIntervalMinute(Date startDate,
Date endDate) |
static int |
getMonth(Date date) |
static List<String> |
getMonthRange(int year,
int month)
获得指定年月的所有日期
|
static List<String> |
getMonthRange(String strBeginDate,
String strEndDate,
String pattern) |
static Date |
getNextDate() |
static String |
getNiceString(int value)
according to the pattern yyyy-MM-dd
|
static String |
getStringDate(Calendar calendar)
format the date into string value
|
static String |
getWeek(Date date) |
static List<Date> |
getWeekDayOfYear(Date date)
一周的日期
|
static int |
getWeekOfYear(Date date) |
static List<String> |
getWeekRange(String strBeginDate,
String strEndDate,
String pattern) |
static int |
getYear(Date date) |
static List<String> |
getYearRange(int fromYear,
int toYear)
指定年范围
|
static Date |
parseDate(String date)
parse date with the default pattern
|
static Date |
parseDate(String date,
String pattern) |
public static Date parseDate(String date) throws ParseException
date - string dateParseExceptionpublic static Date parseDate(String date, String pattern) throws ParseException
ParseExceptionpublic static Date addHour(Date date, int v)
date - 时间v - 值public static String formatDate(Date date)
date - the date that want to format to stringpublic static String formatDate(Date date, String pattern)
date - the date that want to format to stringpattern - the formated patternpublic static String getCurrentDateFormat()
public static String getCurrentTimeFormat()
public static int getDateNum(Date fromDate, Date endDate)
fromDate - the begin dateendDate - the end datepublic static Date addDate(Date date, int number)
date - the added datenumber - the number to add to the datepublic static Calendar getDefaultCalendar()
public static String getStringDate(Calendar calendar)
calendar - the formated calendarpublic static String getNiceString(int value)
value - the valuepublic static Calendar getCalendarFromDate(Date date)
date - the passing datepublic static String getInterval(long intervalTime)
public static int getYear(Date date)
public static int getMonth(Date date)
public static int getDayOfMonth(Date date)
public static int getHour(Date now)
public static int getWeekOfYear(Date date)
public static Date getCurrentDate()
public static String getCurrentDateStr()
public static Date getNextDate()
public static int getDayOfWeek(Date date)
date - 日期public static Date getDefaultDate()
public static boolean betweenHour(Date date, int hour)
public static boolean betweenMinute(Date date, int minute)
public static boolean betweenSecond(Date date, int second)
public static String getCurrentWeekDay(Date date, int day)
date - 指定的日期day - 那一天public static List<String> getYearRange(int fromYear, int toYear)
fromYear - 从那一年toYear - 到那一年public static List<String> getMonthRange(int year, int month)
year - 年month - 月public static List<String> getDateRange(String strBeginDate, String strEndDate, String pattern) throws ParseException
ParseExceptionpublic static List<String> getWeekRange(String strBeginDate, String strEndDate, String pattern) throws ParseException
ParseExceptionpublic static List<String> getMonthRange(String strBeginDate, String strEndDate, String pattern) throws ParseException
ParseExceptionpublic static String getCurrentDateTime()
Copyright © 2017. All rights reserved.