public class TimeUtils extends Object
限定符和类型 | 方法和说明 |
---|---|
static String |
addDay(String currentDate,
int addDay)
得到当前日期加上某一个整数的日期,整数代表天数
|
static String |
convert8Bit(String str)
将YYYY-MM-DD形式改成YYYYMMDD
|
static long |
convertLong(String str)
转换时间yyyy-MM-dd HH:mm:ss到毫秒数
|
static long |
convertLong(String pattern,
String str) |
static String |
convertStandard(String str)
将YYYYMMDD形式改成YYYY-MM-DD
|
static Date |
convertToDate(String date)
转换字符(yyyy-MM-dd)串日期到Date
|
static Date |
convertToDate(String pattern,
String date)
转换字符pattern串日期到Date
|
static String |
convertToString(Date date)
转换日期到字符换yyyy-MM-dd
|
static String |
convertToString(Date date,
String pattern) |
static String |
convertToString(String srcPattern,
String dstPattern,
String time) |
static String |
format(long time,
String pattern)
将long形式改成pattern
|
static String |
format(long time,
String pattern,
int zone)
将long形式改成pattern
|
static String |
formatHm(long time)
将long形式改成HH:mm
|
static String |
formatHm(long time,
int zone)
将long形式改成MM-dd HH:mm
|
static String |
formatHms(long time)
将long形式改成HH:mm:ss
|
static String |
formatHms(long time,
int zone)
将long形式改成MM-dd HH:mm:ss
|
static String |
formatLatelyTime(String strTime)
格式化为应用 常见显示格式 当前天显示时间,其他显示年月日
|
static String |
formatMdHms(long time)
将long形式改成MM-dd HH:mm:ss
|
static String |
formatMdHms(long time,
int zone)
将long形式改成MM-dd HH:mm:ss
|
static String |
formatMs(long time)
将long形式改成mm:ss
|
static String |
formatMs(long time,
int zone)
将long形式改成mm:ss
|
static String |
formatRecentTime(String time)
计算距今的时间
|
static String |
formatYmd(long time)
将long形式改成yyyy-MM-dd
|
static String |
formatYmd(long time,
int zone)
将long形式改成yyyy-MM-dd
|
static String |
formatYmdHms(long time)
将long形式改成yyyy-MM-dd HH:mm:ss
|
static String |
formatYmdHms(long time,
int zone)
将long形式改成yyyy-MM-dd HH:mm:ss
|
static String |
getCurrentDate()
得到当前的日期,共10位 返回格式:yyyy-MM-dd
|
static String |
getCurrentDay()
得到当前的日期 返回格式:dd
|
static String |
getCurrentHoursMinutes()
得到当前的时间 返回格式:HH:mm:
|
static String |
getCurrentMonth()
得到当前的月份 返回格式:MM
|
static String |
getCurrentTime()
得到当前的时间,精确到毫秒,共14位 返回格式:yyyy-MM-dd HH:mm:ss
|
static String |
getCurrentTime(String pattern)
得到当前的时间,返回格式:pattern
|
static String |
getCurrentTimeAddYear(int addYear)
得到当前的时间加上输入年后的时间,精确到毫秒,共19位 返回格式:yyyy-MM-dd:HH:mm:ss
|
static String |
getCurrentYear()
得到当前的年份 返回格式:yyyy
|
static String |
getDate8Bit()
得到当前的日期,共8位 返回格式:yyyyMMdd
|
static String |
getEndDateInPeriod(String period)
得到当前月份的最后一天
|
static String |
getFormatDate(int year,
int monthOfYear,
int dayOfMonth)
获取格式化日期yyyy-MM-dd
|
static String |
getFormatTime(int hourOfDay,
int minute)
获取格式化时间HH:mm
|
static String |
getStartDateInPeriod(String period)
得到当前月份的第一天日期
|
static String |
getZhTimeString(String time)
转化为中文时间格式
|
static boolean |
isSameDay(long time1,
long time2)
判断是同一天
|
static boolean |
isSameMonth(long time1,
long time2)
判断是同一月
|
static boolean |
isSameWeek(long time1,
long time2)
判断是同一周
|
public static String getCurrentYear()
public static String getCurrentMonth()
public static String getCurrentDay()
public static String getCurrentHoursMinutes()
public static String getCurrentTime()
public static Date convertToDate(String pattern, String date)
date
- public static String getCurrentTimeAddYear(int addYear)
public static String getCurrentDate()
public static String getDate8Bit()
public static String addDay(String currentDate, int addDay)
currentDate
- String 格式 yyyy-MM-ddaddDay
- intpublic static String getStartDateInPeriod(String period)
period
- yyyy-MMpublic static String getEndDateInPeriod(String period)
period
- yyyy-MMpublic static String convertStandard(String str)
str
- public static String convertToString(String srcPattern, String dstPattern, String time)
public static long convertLong(String str)
str
- public static String formatYmdHms(long time, int zone)
time
- zone
- public static String formatYmd(long time, int zone)
time
- zone
- public static String formatMdHms(long time, int zone)
time
- zone
- public static String formatHms(long time, int zone)
time
- zone
- public static String formatHm(long time, int zone)
time
- zone
- public static String formatMs(long time, int zone)
time
- zone
- public static String format(long time, String pattern, int zone)
time
- pattern
- public static String formatYmdHms(long time)
time
- public static String formatYmd(long time)
public static String formatMdHms(long time)
time
- public static String formatHms(long time)
time
- public static String formatHm(long time)
time
- public static String formatMs(long time)
time
- public static String format(long time, String pattern)
time
- pattern
- public static String getFormatDate(int year, int monthOfYear, int dayOfMonth)
year
- monthOfYear
- dayOfMonth
- public static String getFormatTime(int hourOfDay, int minute)
hourOfDay
- minute
- public static String formatLatelyTime(String strTime)
strTime
- yyyy-MM-dd HH:mm:sspublic static boolean isSameDay(long time1, long time2)
time1
- time2
- public static boolean isSameMonth(long time1, long time2)
time1
- time2
- public static boolean isSameWeek(long time1, long time2)
time1
- time2
-