类 TimeUtil
- java.lang.Object
-
- cn.vorbote.commons.TimeUtil
-
public final class TimeUtil extends Object
TimeUtil can transfer unix/java timestamps to Date object.- 作者:
- TheodoreHills
-
-
字段概要
字段 修饰符和类型 字段 说明 static StringJAVA_TIMESTAMPstatic StringUNIX_TIMESTAMP
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static StringDateToString(Date date, String pattern)Transfer Date to Stringstatic CalendarGetCalendar(Date date)Get the calendar instance by a date instance.static DateGetDate(int year, int month, int date)Create a date instance bycalendar.static DateGetDate(Calendar calendar)Create a date instance bycalendar.static longNow()Get the unix timestamp.static longNow(boolean isUnixTimestamp)Get the timestamp.static DateTimestampToDate(String strDate)Transfer timestamp to class java.util.Date
-
-
-
方法详细资料
-
TimestampToDate
public static Date TimestampToDate(String strDate)
Transfer timestamp to class java.util.Date- 参数:
strDate- timestamp- 返回:
- The Date object if succeed, current date if failed
-
DateToString
public static String DateToString(Date date, String pattern)
Transfer Date to String- 参数:
date- Date objectpattern- The pattern of the string- 返回:
- Converted String
-
GetDate
public static Date GetDate(int year, int month, int date)
Create a date instance bycalendar.- 参数:
year- The year num such as 2021.month- The month num such asCalendar.JANUARYdate- The date in that month.- 返回:
- The date instance created by the specified date.
-
GetDate
public static Date GetDate(Calendar calendar)
Create a date instance bycalendar.- 参数:
calendar- The calendar instance.- 返回:
- The date instance created by the specified date.
-
GetCalendar
public static Calendar GetCalendar(Date date)
Get the calendar instance by a date instance.- 参数:
date- The date instance.- 返回:
- The calendar instance.
-
Now
public static long Now()
Get the unix timestamp.- 返回:
- The timestamp in specific format.
-
Now
public static long Now(boolean isUnixTimestamp)
Get the timestamp.- 参数:
isUnixTimestamp- If you need unit timestamp, then put a true in it.- 返回:
- The timestamp in specific format.
-
-