public class DateUtils
extends java.lang.Object
限定符和类型 | 字段和说明 |
---|---|
static java.lang.String |
CHN_DATE_FORMAT |
static java.lang.String |
CHN_DATE_TIME_EXTENDED_FORMAT |
static java.lang.String |
CHN_DATE_TIME_EXTENDED_LONG_FORMAT1 |
static java.lang.String |
CHN_DATE_TIME_EXTENDED_LONG_FORMAT2 |
static java.lang.String |
CHN_DATE_TIME_EXTENDED_LONG_FORMAT3 |
static java.lang.String |
CHN_DATE_TIME_FORMAT |
static java.lang.String |
DATE_FORMAT |
static java.lang.String |
DATE_TIME_EXTENDED_FORMAT |
static java.lang.String |
DATE_TIME_EXTENDED_LONG_FORMAT1 |
static java.lang.String |
DATE_TIME_EXTENDED_LONG_FORMAT2 |
static java.lang.String |
DATE_TIME_EXTENDED_LONG_FORMAT3 |
static java.lang.String |
DATE_TIME_FORMAT |
static java.lang.String |
ORA_DATE_FORMAT |
static java.lang.String |
ORA_DATE_TIME_EXTENDED_FORMAT |
static java.lang.String |
ORA_DATE_TIME_FORMAT |
static java.lang.String |
ORA_TIME_EXTENDED_FORMAT |
构造器和说明 |
---|
DateUtils() |
DateUtils(int year,
int month,
int day,
int hour,
int minute,
int second) |
DateUtils(long mills) |
DateUtils(java.lang.String inValue) |
限定符和类型 | 方法和说明 |
---|---|
void |
add(int years,
int months,
int days,
int hours,
int minutes,
int seconds) |
void |
addDay(int days) |
void |
addHour(int hours) |
void |
addMinute(int minutes) |
void |
addMonth(int months) |
void |
addSecond(int seconds) |
void |
addYear(int years) |
int |
daysOfMonth() |
static long |
diffSec(DateUtils dataOne,
DateUtils dataOther) |
static java.lang.String |
format(java.util.Date df) |
java.lang.String |
format(java.text.SimpleDateFormat df) |
java.lang.String |
format2(java.lang.String strFormat) |
java.lang.String |
format3(java.lang.String strFormat) |
java.lang.String |
formatDate(java.lang.Object date)
格式化日期成时间字符串
|
java.lang.String |
formatDate(java.lang.Object date,
java.lang.String pattern)
格式化日期成时间字符串
|
static java.util.Date |
formatNowToDate() |
static java.util.Date |
formatToDate(java.lang.String date) |
java.lang.String |
getCurrentDate(java.text.SimpleDateFormat dateFormat) |
int |
getDay() |
int |
getDayOfMonth(int ms) |
int |
getHour() |
int |
getMinute() |
int |
getMonth() |
int |
getSecond() |
long |
getTimeInMillis() |
int |
getYear() |
boolean |
isLeapYear() |
boolean |
isLeapYear(int year) |
static boolean |
isValidDate(java.lang.String s,
java.text.SimpleDateFormat dateFormat) |
static java.util.Date |
parse(java.lang.String strDate)
把字符串的转成Date类型
|
void |
setDate(java.lang.String inValue) |
void |
setDay(int day) |
void |
setHour(int hour) |
void |
setMinute(int minute) |
void |
setMonth(int month) |
void |
setSecond(int second) |
void |
setTimeInMillis(long mills) |
void |
setYear(int year) |
java.lang.String |
toString() |
static java.util.Date |
tryParse(java.lang.String strDate)
尝试吧字符串的转成Date类型 包含了三种通用格式的串 yyyy/MM/dd , yyyyMMdd , yyyy-MM-dd
|
public static final java.lang.String DATE_FORMAT
public static final java.lang.String DATE_TIME_FORMAT
public static final java.lang.String DATE_TIME_EXTENDED_FORMAT
public static final java.lang.String DATE_TIME_EXTENDED_LONG_FORMAT1
public static final java.lang.String DATE_TIME_EXTENDED_LONG_FORMAT2
public static final java.lang.String DATE_TIME_EXTENDED_LONG_FORMAT3
public static final java.lang.String ORA_DATE_FORMAT
public static final java.lang.String ORA_DATE_TIME_FORMAT
public static final java.lang.String ORA_DATE_TIME_EXTENDED_FORMAT
public static final java.lang.String ORA_TIME_EXTENDED_FORMAT
public static final java.lang.String CHN_DATE_FORMAT
public static final java.lang.String CHN_DATE_TIME_FORMAT
public static final java.lang.String CHN_DATE_TIME_EXTENDED_FORMAT
public static final java.lang.String CHN_DATE_TIME_EXTENDED_LONG_FORMAT1
public static final java.lang.String CHN_DATE_TIME_EXTENDED_LONG_FORMAT2
public static final java.lang.String CHN_DATE_TIME_EXTENDED_LONG_FORMAT3
public DateUtils()
public DateUtils(java.lang.String inValue)
DateUtils(long mills)
DateUtils(int year, int month, int day, int hour, int minute, int second)
public void setDate(java.lang.String inValue)
public java.lang.String format(java.text.SimpleDateFormat df)
public static java.lang.String format(java.util.Date df)
public java.lang.String format2(java.lang.String strFormat)
public java.lang.String format3(java.lang.String strFormat)
public java.lang.String formatDate(java.lang.Object date, java.lang.String pattern)
date
- 时间pattern
- 时间字符串模板public java.lang.String formatDate(java.lang.Object date)
date
- 时间public java.lang.String toString()
toString
在类中 java.lang.Object
public int getDay()
public void setDay(int day)
public int getHour()
public void setHour(int hour)
public int getMinute()
public void setMinute(int minute)
public int getMonth()
public void setMonth(int month)
public int getSecond()
public void setSecond(int second)
public int getYear()
public void setYear(int year)
public long getTimeInMillis()
public void setTimeInMillis(long mills)
public boolean isLeapYear()
public boolean isLeapYear(int year)
public void add(int years, int months, int days, int hours, int minutes, int seconds)
public void addYear(int years)
public void addMonth(int months)
public void addDay(int days)
public void addHour(int hours)
public void addMinute(int minutes)
public void addSecond(int seconds)
public int daysOfMonth()
public int getDayOfMonth(int ms)
public static boolean isValidDate(java.lang.String s, java.text.SimpleDateFormat dateFormat)
public java.lang.String getCurrentDate(java.text.SimpleDateFormat dateFormat)
public static java.util.Date parse(java.lang.String strDate) throws java.text.ParseException
strDate
- 时间字符串java.text.ParseException
- 出错会抛出异常public static java.util.Date tryParse(java.lang.String strDate) throws java.lang.Exception
strDate
- 时间字符串java.lang.Exception
- 出错会抛出异常public static java.util.Date formatNowToDate() throws java.text.ParseException
java.text.ParseException
public static java.util.Date formatToDate(java.lang.String date) throws java.text.ParseException
java.text.ParseException