public abstract class DatetimeOpt extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
datetimePattern |
static String |
defaultDatePattern |
static String |
gmtDatePattern |
static String |
timePattern |
static String |
timestampPattern |
static String |
timeWithSecondPattern |
| 限定符和类型 | 方法和说明 |
|---|---|
static Date |
addDays(Date date,
float nDays) |
static Date |
addDays(Date date,
int nDays) |
static Date |
addHours(Date date,
int nHours) |
static Date |
addMinutes(Date date,
int nMinutes) |
static Date |
addMonths(Date date,
int nMonths) |
static Date |
addSeconds(Date date,
int nSeconds) |
static Date |
addYears(Date date,
int nYears) |
static double |
calcDateSpan(Date beginDate,
Date endDate) |
static int |
calcSpanDays(Date beginDate,
Date endDate) |
static Date |
calcWeek1stDay(int nYear,
int nWeekNo) |
static int |
calcWeekDays(Date beginDate,
Date endDate,
int weekDay)
计算这个周期中 工作日的天数,不包括 周六和周日,但是因为不知道其他的假期,所以只是去掉周末
|
static int |
calcWeekendDays(Date beginDate,
Date endDate)
计算这个周期中的周六和周日的天数,周末的天数
|
static Date |
calcWeekLastDay(int nYear,
int nWeekNo) |
static Date |
castObjectToDate(Object obj) |
static Date |
castObjectToSqlDate(Object date) |
static Timestamp |
castObjectToSqlTimestamp(Object date) |
static int |
compareTwoDate(Date oneDate,
Date otherDate)
比较两个日期大小 ,避免 发生 NullPointerException 异常
Compares two Dates for ordering.
|
static String |
convertDatetimeToString(Date aDate)
返回日期字符串 "yyyy-MM-dd HH:mm:ss"
|
static String |
convertDateToGMTString(Date aDate)
返回日期字符串 toUTCString( ) 和 javaScript 一致
// d MMM yyyy HH:mm:ss 'GMT'
|
static String |
convertDateToSmartString(Date aDate) |
static String |
convertDateToSmartString(Date aDate,
boolean withSecond) |
static String |
convertDateToString(Date aDate)
返回日期字符串 "yyyy-MM-dd"
|
static String |
convertDateToString(Date aDate,
String aMask)
This method generates a string representation of a date's date/time in
the format you specify on input
|
static Date |
convertStringToDate(String strDate)
This method converts a String to a date using the datePattern
|
static Date |
convertStringToDate(String strDate,
String sMask)
This method generates a string representation of a date/time in the
format you specify on input
|
static String |
convertTimestampToString(Date aDate) |
static String |
convertTimeToString(Date aDate)
This method generates a string representation of a date based on the
System Property 'dateFormat' in the format you specify on input
|
static String |
convertTimeWithSecondToString(Date aDate) |
static Date |
convertToSqlDate(Date date)
日期类型转换 从 java.util.Date 转换为 java.sql.Date 这个会截断时间
|
static Timestamp |
convertToSqlTimestamp(Date date)
日期类型转换 从 java.util.Date 转换为 java.sql.Timestamp
|
static Date |
convertToUtilDate(Date date)
日期类型转换 从 java.sql.Date 转换为 java.util.Date 这个会截断时间
|
static Date |
createUtilDate(int year,
int month,
int date)
根据 年、月、日 创建一个日期 类型为 java.util.Date
|
static Date |
createUtilDate(int year,
int month,
int date,
int hourOfDay,
int minute)
根据 年、月、日、时、分 创建一个日期 类型为 java.util.Date
|
static Date |
createUtilDate(int year,
int month,
int date,
int hourOfDay,
int minute,
int second)
根据 年、月、日、时、分、秒 创建一个日期 类型为 java.util.Date
|
static Date |
createUtilDate(int year,
int month,
int date,
int hourOfDay,
int minute,
int second,
int milliSecond) |
static Calendar |
currentCalendarDate() |
static String |
currentDate()
获得当前日期的字符串 ,格式为 "yyyy-MM-dd" 示例 2015-08-24
|
static String |
currentDatetime()
获得当前日期的字符串 ,格式为 "yyyy-MM-dd HH:mm:ss"
|
static Date |
currentSqlDate() |
static Timestamp |
currentSqlTimeStamp() |
static String |
currentTime() |
static String |
currentTimeWithSecond() |
static Date |
currentUtilDate() |
static boolean |
equalOnDay(Date oneDate,
Date otherDate) |
static boolean |
equalOnHour(Date oneDate,
Date otherDate) |
static boolean |
equalOnMinute(Date oneDate,
Date otherDate) |
static boolean |
equalOnSecond(Date oneDate,
Date otherDate) |
static Locale |
fetchLangLocal(String lang) |
static TimeZone |
fetchTimeZone(String zone)
时区转换
|
static String |
getDatePattern()
返回常量字符串 "yyyy-MM-dd"
|
static String |
getDateTimePattern() |
static int |
getDay(Date date) |
static int |
getDayOfWeek(Date date)
获得 指定日期 是星期几 星期日 到星期六 为 0-6
|
static int |
getDayOfWeek(int y,
int m,
int d)
获得 年月日 对应的日期 是星期几 星期日 到星期六 为 0-6
|
static String |
getDayOfWeekCN(Date date)
获得 指定日期 是星期几 星期日 到星期六 为 "星期日","星期一","星期二","星期三","星期四","星期五","星期六"
|
static int |
getDayOfYear(Date date) |
static int |
getHour(Date date) |
static int |
getMilliSecond(Date date) |
static int |
getMinute(Date date) |
static int |
getMonth(Date date) |
static String |
getNowDateTime4String()
获得当前时间字符串,格式为 "yyyy-MM-dd HH:mm:ss"
|
static int |
getSecond(Date date) |
static int |
getWeekOfMonth(Date date) |
static int |
getWeekOfYear(Date date) |
static int |
getYear(Date date) |
static Date |
seekEndOfMonth(Date date) |
static Date |
seekEndOfWeek(Date date)
获取一周最后一天(周日凌晨零点)
|
static Date |
seekEndOfYear(Date date) |
static Date |
smartPraseDate(String sDate) |
static Date |
truncateToDay(Date date) |
static Date |
truncateToMonth(Date date) |
static Date |
truncateToSecond(Date date) |
static Date |
truncateToWeek(Date date)
获取一周第一天(周一凌晨零点)
|
static Date |
truncateToYear(Date date) |
public static String currentDate()
public static String currentTime()
public static String currentTimeWithSecond()
public static String currentDatetime()
public static Date createUtilDate(int year, int month, int date, int hourOfDay, int minute, int second, int milliSecond)
public static Date createUtilDate(int year, int month, int date, int hourOfDay, int minute, int second)
year - 年month - 月date - 日hourOfDay - 时 (24小时制)minute - 分second - 秒public static Date createUtilDate(int year, int month, int date, int hourOfDay, int minute)
year - 年month - 月date - 日hourOfDay - 时 (24小时制)minute - 分public static Date createUtilDate(int year, int month, int date)
year - 年month - 月date - 日public static Date convertToUtilDate(Date date)
date - 时间public static Date convertToSqlDate(Date date)
date - 时间public static Timestamp convertToSqlTimestamp(Date date)
date - 时间public static Date currentSqlDate()
public static Date currentUtilDate()
public static Timestamp currentSqlTimeStamp()
public static Calendar currentCalendarDate()
public static String getDatePattern()
public static String getDateTimePattern()
public static TimeZone fetchTimeZone(String zone)
zone - 长度为3的时区public static Date convertStringToDate(String strDate, String sMask)
sMask - the date pattern the string is instrDate - a string representation of a date的说明public static String convertDateToString(Date aDate, String aMask)
aMask - the date pattern the string is inaDate - a date object的说明public static String convertTimeToString(Date aDate)
aDate - A date to convertpublic static String convertDateToString(Date aDate)
aDate - 时间public static String convertDateToSmartString(Date aDate, boolean withSecond)
public static String convertDateToGMTString(Date aDate)
aDate - 时间public static String convertDatetimeToString(Date aDate)
aDate - 时间public static String getNowDateTime4String()
public static Date convertStringToDate(String strDate)
strDate - the date to convert (in format yyyy-mm-dd)public static int getDayOfWeek(int y,
int m,
int d)
y - 年m - 月d - 日public static int getDayOfWeek(Date date)
date - 日期public static String getDayOfWeekCN(Date date)
date - 日期public static int getSecond(Date date)
public static int getMilliSecond(Date date)
public static int getMinute(Date date)
public static int getHour(Date date)
public static int getWeekOfYear(Date date)
public static int getWeekOfMonth(Date date)
public static int getDay(Date date)
public static int getDayOfYear(Date date)
public static int getMonth(Date date)
public static int getYear(Date date)
public static Date truncateToWeek(Date date)
date - 输入时间public static Date seekEndOfWeek(Date date)
date - 输入时间public static int calcSpanDays(Date beginDate, Date endDate)
beginDate - beginTimeendDate - endTimepublic static double calcDateSpan(Date beginDate, Date endDate)
beginDate - beginTimeendDate - endTimepublic static Date calcWeek1stDay(int nYear, int nWeekNo)
public static Date calcWeekLastDay(int nYear, int nWeekNo)
public static int calcWeekendDays(Date beginDate, Date endDate)
beginDate - beginTimeendDate - endTimepublic static int calcWeekDays(Date beginDate, Date endDate, int weekDay)
beginDate - beginTimeendDate - endTimeweekDay - 0~6 "星期日","星期一","星期二","星期三","星期四","星期五","星期六"public static int compareTwoDate(Date oneDate, Date otherDate)
oneDate - the Date to be compared.otherDate - the Date to be compared.0 if the argument otherDate is equal to
oneDate ; a value less than 0 if this Date
is before the Date argument; and a value greater than
if oneDate is after the otherDate.Copyright © 2025 姹熻嫃鍗楀ぇ鍏堣吘淇℃伅浜т笟鑲′唤鏈夐檺鍏徃. All rights reserved.