public class DateUtil extends Object
Constructor and Description |
---|
DateUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
dateToBOMCStringDate(Date date)
return string value of specified date in format: yyyy-MM-ddTHH:mm:ss
|
static String |
dateToLongString(Date date)
return time value of specified date in format: yyyy-MM-dd HH:mm:ss
|
static String |
dateToShortString(Date date)
return date value only of specified date in format: yyyy-MM-dd
|
static String |
dateToString(Date date)
return time value of specified date in format: yyyy-MM-dd HH:mm
|
static String |
dateToStringWithPattern(Date date,
String pattern)
return time value of specified date
|
static String |
dateToTimeString(Date date)
return time value only of specified date in format: HH:mm:ss
|
static long |
getCurrentTimestamp()
return unix timestamp of now
|
static Date |
getDate(Date date,
int field,
int amount)
return date value with specified field value
|
static Date |
getMonthFirstDay(String dateString)
return the first day of the date's month of specified string value in format: yyyy-MM
|
static Date |
getMonthLastDay(String dateString)
return the last day of the date's month of specified string value in format: yyyy-MM
|
static Date |
getNow()
return date value of now
|
static String |
getNowDate()
return current date value in format: yyyy-MM-dd
|
static String |
getNowTime()
return current time value in format: yyyy-MM-dd HH:mm:ss:sss
|
static long |
getOffMinutes(long timestamp)
return the time difference from a specified time to now in minutes
|
static long |
getOffMinutes(long left,
long right)
return the time difference from two specified time
|
static long |
getStringToTimestamp(String string)
return unix timestamp of specified string value in format: yyyy-MM-dd HH:mm:ss
|
static long |
getTimestamp(String string)
return unix timestamp of specified string value in format: yyyy-MM-dd
|
static Date |
getWeekDay(String dateString,
int weekDay)
return date's weekday value of specified string value in format: yyyy-MM-dd Date first =
DateUtil.getMonday(today,Calendar.SUNDAY); Date last = DateUtil.getMonday(today,Calendar.SATURDAY);
|
static Date |
getYearFirstDay(String dateString)
return the first day of the date's year of specified string value in format: yyyy
|
static Date |
getYearLastDay(String dateString)
return the last day of the date's year of specified string value in format: yyyy
|
static String |
LongToDateString(long timestamp)
return string value of specified unix timestamp
|
static String[] |
SplitDate(Date date)
split date value of specified date by '-'
|
static String |
StringToBOMCStringDate(String date)
return handled string value of date
|
static Date |
stringToDate(String string)
return date value of specified string value in format: yyyy-MM-dd HH:mm:ss
|
static Date |
stringToShortDate(String string)
return date value of specified string value in format: yyyy-MM-dd
|
static Date |
stringToShortNoDate(String string)
return date value of specified string value in format: yyyyMMdd
|
static Date |
timeStringToDate(String string)
return date value of specified string value in format: HH:mm:ss
|
public static String getNowDate()
public static String getNowTime()
public static String dateToString(Date date)
date
- the specified date to convertpublic static String dateToShortString(Date date)
date
- the specified date to convertpublic static String dateToLongString(Date date)
date
- the specified date to convertpublic static String dateToTimeString(Date date)
date
- the specified date to convertpublic static String dateToStringWithPattern(Date date, String pattern)
date
- the specified date to convertpattern
- time formatpublic static String[] SplitDate(Date date)
date
- the specified date to convertpublic static String dateToBOMCStringDate(Date date)
date
- the specified date to convertpublic static String StringToBOMCStringDate(String date)
date
- string value to convertpublic static Date stringToDate(String string)
string
- string value to convertpublic static Date timeStringToDate(String string)
string
- string value to convertpublic static Date stringToShortDate(String string)
string
- string value to convertpublic static Date stringToShortNoDate(String string)
string
- string value to convertpublic static Date getNow()
public static long getCurrentTimestamp()
public static long getTimestamp(String string)
string
- string value to convertpublic static long getStringToTimestamp(String string)
string
- string value to convertpublic static long getOffMinutes(long timestamp)
timestamp
- unix timestamp of a specified timepublic static long getOffMinutes(long left, long right)
left
- unix timestamp of the first specified timeright
- unix timestamp of the second specified timepublic static String LongToDateString(long timestamp)
timestamp
- unix timestamppublic static Date getWeekDay(String dateString, int weekDay)
dateString
- String value of dateweekDay
- int index of weekday to get, first Calendar.SUNDAY, last Calendar.SATURDAYpublic static Date getMonthFirstDay(String dateString)
dateString
- String value of datepublic static Date getMonthLastDay(String dateString)
dateString
- String value of datepublic static Date getYearFirstDay(String dateString)
dateString
- String value of datepublic static Date getYearLastDay(String dateString)
dateString
- String valueCopyright © 2017. All rights reserved.