|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectcom.aiyc.framework.utils.DateUtils
public class DateUtils
日期处理工具类
| 构造方法摘要 | |
|---|---|
DateUtils()
|
|
| 方法摘要 | |
|---|---|
static Date |
addDay(Date date,
int days)
日期和天数相加函数,返回相加后的日期 |
static Date |
addHour(Date date,
int hours)
日期和小时数相加函数,返回相加后的日期 |
static Date |
addMonth(Date date,
int months)
日期和月数相加函数,返回相加后的日期 |
static Date |
addYear(Date date,
int years)
日期和年数相加函数,返回相加后的日期 |
static String |
dateTimeToStr(Date sqlDate)
sql日期型转换为带时间的字符串 格式:yyyy-MM-dd HH:mm:ss |
static String |
dateTimeToStr(Date date)
普通日期型转换为带时间的字符串 格式:yyyy-MM-dd HH:mm:ss |
static String |
dateToStr(Date sqlDate)
sql日期型转换为不带时间的字符串 格式:yyyy-MM-dd |
static String |
dateToStr(Date date)
普通日期型转换为不带时间的字符串 格式:yyyy-MM-dd |
static String |
getCurrentDateStr()
取的服务器北京时间(时区为GMT+8)字符串,格式:yyyy-mm-dd |
static String |
getCurrentHMS()
取的服务器北京时间(时区为GMT+8)字符串。 |
static Date |
getCurrentSqlDate()
取的服务器北京时间(时区为GMT+8) |
static String |
getCurrentTime()
取的服务器北京时间(时区为GMT+8)字符串 |
static String |
getCurrentYearMonth()
取的服务器北京时间(时区为GMT+8)字符串 |
static String |
getDateStr()
取的服务器北京时间(时区为GMT+8)字符串 |
static int |
getDayCount(Date tStartDate,
Date tEndDate)
获取任意两个日期间的天数 |
int |
getMonth(Date date)
获得给定日期的月份 |
static String |
getWeekNumberFromDate(String thedate)
传入yyyy-mm-dd的日期字符串返回yyyy-mm-dd 星期的形式 |
int |
getYear(Date date)
获得给定日期的年份 |
static Date |
strToDate(String str)
字符串转换为普通的日期 |
static Date |
strToDate(String str,
String format)
字符串按照指定的格式转换为普通的日期 |
static Date |
strToSqlDate(String str)
字符串转换为sql的日期 |
static Date |
toSqlDate(Date date)
普通日期型转换sql日期 |
static Date |
toUtilDate(Date date)
sql日期型转换普通日期 |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 构造方法详细信息 |
|---|
public DateUtils()
| 方法详细信息 |
|---|
public static Date addDay(Date date,
int days)
date - Date 日期days - int 相加的天数,负数表示相减
public static Date addHour(Date date,
int hours)
date - Date 日期hour - int 相加的小时数,负数表示相减
public static Date addMonth(Date date,
int months)
date - Date 日期months - int 相加的月数,负数表示相减
public static Date addYear(Date date,
int years)
date - Date 日期years - int 相加的年数,负数表示相减
public static final String getCurrentTime()
public static final String getCurrentHMS()
public static final String getCurrentYearMonth()
public static final String getCurrentDateStr()
public static final String getDateStr()
public static Date getCurrentSqlDate()
public static Date strToDate(String str)
str - 要转换的字符串,可以是日期,也可带分秒,但必须符合日期的格式
public static Date strToSqlDate(String str)
str - 要转换的字符串
public static Date strToDate(String str,
String format)
str - 要转换的字符串,可以是日期,也可带分秒,但必须符合日期的格式format - 自定义格式,比如:yyyymmdd,mm/dd/yy等
public static String dateTimeToStr(Date sqlDate)
sqlDate -
public static String dateToStr(Date sqlDate)
sqlDate -
public static String dateTimeToStr(Date date)
date -
public static String dateToStr(Date date)
date -
public static Date toSqlDate(Date date)
date -
public static Date toUtilDate(Date date)
date -
public int getYear(Date date)
throws NullPointerException
date - 给定日期
NullPointerException - 如果参数年份为null,抛出异常。
public int getMonth(Date date)
throws NullPointerException
date - 给定日期
NullPointerException - 如果参数年份为null,抛出异常。
public static int getDayCount(Date tStartDate,
Date tEndDate)
tStartDate - 起始日期,tEndDate - 结束日期
public static String getWeekNumberFromDate(String thedate)
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||