public class DateUtil extends TimeUtil
| Constructor and Description |
|---|
DateUtil() |
| Modifier and Type | Method and Description |
|---|---|
static Date |
addDate(Date p_startDate,
Integer p_count,
Integer p_field)
在给定的日期基础上添加年,月,日、时,分,秒
例如要再2006-10-21(uitl日期)添加3个月,并且格式化为yyyy-MM-dd格式,
这里调用的方式为 addDate(2006-10-21,3,Calendar.MONTH,"yyyy-MM-dd")
|
static String |
addDate(Date p_startDate,
Integer p_count,
Integer p_field,
String p_format)
在给定的日期基础上添加年,月,日、时,分,秒
例如要再2006-10-21(uitl日期)添加3个月,并且格式化为yyyy-MM-dd格式,
这里调用的方式为 addDate(2006-10-21,3,Calendar.MONTH,"yyyy-MM-dd")
|
static Date |
getAnotherDate(Date date,
int num)
取得某天相加(减)後的那一天
|
static long |
getDaysOfTowDiffDate(String p_startDate,
String p_endDate)
获取2个字符日期的天数差
|
static Date |
getFirstDayOfWeek(Date date)
取得某天所在周的第一天
|
static Date |
getFirstDayOfWeek(int year,
int week)
取得某年某周的第一天 对于交叉:2008-12-29到2009-01-04属于2008年的最后一周,2009-01-05为2009年第一周的第一天
|
static Date |
getLastDayOfMonth(Date date)
取得某月的的最后一天
|
static Date |
getLastDayOfMonth(int year,
int month)
取得某月的的最后一天
|
static Date |
getLastDayOfWeek(Date date)
取得某天所在周的最后一天
|
static Date |
getLastDayOfWeek(int year,
int week)
取得某年某周的最后一天 对于交叉:2008-12-29到2009-01-04属于2008年的最后一周, 2009-01-04为
2008年最后一周的最后一天
|
static int |
getMaxWeekNumOfYear(int year)
取得某一年共有多少周
|
static long |
getMonthsOfTowDiffDate(String p_startDate,
String p_endDate)
获取2个字符日期的月数差
|
static int |
getWeekOfYear(Date date)
取得某天是一年中的多少周
|
static long |
getWeeksOfTowDiffDate(String p_startDate,
String p_endDate)
获取2个字符日期的周数差
|
static long |
getYearsOfTowDiffDate(String p_startDate,
String p_endDate)
获取2个字符日期的年数差
|
static boolean |
isLeapYear(Date p_date)
判断给定日期是不是润年
|
static boolean |
isStartDateBeforeEndDate(Date p_startDate,
Date p_endDate)
是否开始日期在结束日期之前(不包括相等)
|
getDateOfMonthBegin, getDateOfMonthEnd, getDayOfDate, getDayOfMonth, getHourOfDate, getHoursOfTowDiffDate, getMillisOfDate, getMillisOfTowDiffDate, getMillisOfTowDiffDate, getMinuteOfDate, getMinutesOfTowDiffDate, getMonthOfDate, getNowOfDateByFormat, getSecondOfDate, getSeconds, getSecondsOfTowDiffDate, getStrTimeByUTC, getSystemOfDateByFormat, getYearOfDate, getYesterdayOfDateByFormat, toCalendarFromUtilDate, toSqlDateFromStrDate, toSqlDateFromUtilDate, toSqlTimeFromUtilDate, toSqlTimestampFromUtilDate, toStrDateFromUtilDateByFormat, toUtilDateFromSqlDate, toUtilDateFromStrDateByFormatdateTo14String, dateTo18String, dateToChineseString, formatDateToDHMSString, formatDateToHMSString, formatDateToMMddHHmm, formatDateToMysqlString, formatDateToyyMMddHHmm, formatTimestampToMysqlString, parseHMSStringToDate, parseStringToMysqlDate, parseStringToYMD, string14ToDatepublic static boolean isStartDateBeforeEndDate(Date p_startDate, Date p_endDate) throws ParseException
p_startDate - 开始时间p_endDate - 结束时间ParseException - 转换出错public static long getDaysOfTowDiffDate(String p_startDate, String p_endDate) throws ParseException
p_startDate - 开始p_endDate - 结束ParseException - 转换出错public static long getWeeksOfTowDiffDate(String p_startDate, String p_endDate) throws ParseException
p_startDate - 开始p_endDate - 结束ParseException - 转换出错public static long getMonthsOfTowDiffDate(String p_startDate, String p_endDate) throws ParseException
p_startDate - 开始p_endDate - 结束ParseException - 转换出错public static long getYearsOfTowDiffDate(String p_startDate, String p_endDate) throws ParseException
p_startDate - 开始p_endDate - 结束ParseException - 转换出错public static String addDate(Date p_startDate, Integer p_count, Integer p_field, String p_format) throws ParseException
p_startDate - 给定的日期p_count - 时间的数量p_field - 添加的域p_format - 时间转化格式,例如:yyyy-MM-dd hh:mm:ss 或者yyyy-mm-dd等ParseException - 转换出错
: 2006-10-31public static Date addDate(Date p_startDate, Integer p_count, Integer p_field) throws ParseException
p_startDate - 给定的日期p_count - 时间的数量p_field - 添加的域ParseException - 转换出错
: 2006-10-31public static boolean isLeapYear(Date p_date)
p_date - 给定日期public static Date getAnotherDate(Date date, int num)
date - 日期num(可正可负) - public static Date getLastDayOfMonth(int year, int month)
year - 年month - 月public static Date getLastDayOfMonth(Date date) throws ParseException
date - 某月ParseException - 转换错误
: 2010-7-21public static int getWeekOfYear(Date date)
date - 日期public static Date getFirstDayOfWeek(Date date)
date - 日期public static Date getLastDayOfWeek(Date date)
date - 日期public static int getMaxWeekNumOfYear(int year)
year - 年public static Date getFirstDayOfWeek(int year, int week)
year - 年week - 周public static Date getLastDayOfWeek(int year, int week)
year - 年week - 周Copyright © 2017. All rights reserved.