Package org.gitlab4j.api.utils
Class ISO8601
- java.lang.Object
-
- org.gitlab4j.api.utils.ISO8601
-
public class ISO8601 extends java.lang.ObjectThis class provides utility methods for parsing and formatting ISO8601 formatted dates.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDATE_ONLY_PATTERNstatic java.lang.StringMSEC_PATTERNstatic java.lang.StringOUTPUT_MSEC_PATTERNstatic java.lang.StringOUTPUT_PATTERNstatic java.lang.StringPATTERNstatic java.lang.StringPATTERN_MSECstatic java.lang.StringSPACEY_MSEC_PATTERNstatic java.lang.StringSPACEY_PATTERNstatic java.lang.StringUTC_PATTERN
-
Constructor Summary
Constructors Constructor Description ISO8601()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringdateOnly(java.util.Date date)Get a string that includes the date only in yyyy-mm-ss format.static java.lang.StringgetTimestamp()Get a ISO8601 formatted string for the current date and time.static java.lang.StringgetTimestamp(boolean withMsec)Get a ISO8601formatted string for the current date and time.static java.util.CalendartoCalendar(java.lang.String dateTimeString)Parses an ISO8601 formatted string a returns a Calendar instance.static java.util.DatetoDate(java.lang.String dateTimeString)Parses an ISO8601 formatted string a returns a Date instance.static java.time.InstanttoInstant(java.lang.String dateTimeString)Parses an ISO8601 formatted string a returns an Instant instance.static java.lang.StringtoString(java.util.Calendar cal)Get a ISO8601 formatted string for the provided Calendar instance.static java.lang.StringtoString(java.util.Date date)Get a ISO8601 formatted string for the provided Date instance.static java.lang.StringtoString(java.util.Date date, boolean withMsec)Get a ISO8601 formatted string for the provided Date instance.
-
-
-
Field Detail
-
PATTERN
public static final java.lang.String PATTERN
- See Also:
- Constant Field Values
-
MSEC_PATTERN
public static final java.lang.String MSEC_PATTERN
- See Also:
- Constant Field Values
-
SPACEY_PATTERN
public static final java.lang.String SPACEY_PATTERN
- See Also:
- Constant Field Values
-
SPACEY_MSEC_PATTERN
public static final java.lang.String SPACEY_MSEC_PATTERN
- See Also:
- Constant Field Values
-
PATTERN_MSEC
public static final java.lang.String PATTERN_MSEC
- See Also:
- Constant Field Values
-
OUTPUT_PATTERN
public static final java.lang.String OUTPUT_PATTERN
- See Also:
- Constant Field Values
-
OUTPUT_MSEC_PATTERN
public static final java.lang.String OUTPUT_MSEC_PATTERN
- See Also:
- Constant Field Values
-
UTC_PATTERN
public static final java.lang.String UTC_PATTERN
- See Also:
- Constant Field Values
-
DATE_ONLY_PATTERN
public static final java.lang.String DATE_ONLY_PATTERN
- See Also:
- Constant Field Values
-
-
Method Detail
-
getTimestamp
public static java.lang.String getTimestamp()
Get a ISO8601 formatted string for the current date and time.- Returns:
- a ISO8601 formatted string for the current date and time
-
getTimestamp
public static java.lang.String getTimestamp(boolean withMsec)
Get a ISO8601formatted string for the current date and time.- Parameters:
withMsec- flag indicating whether to include milliseconds- Returns:
- a ISO8601 formatted string for the current date and time
-
toString
public static java.lang.String toString(java.util.Calendar cal)
Get a ISO8601 formatted string for the provided Calendar instance.- Parameters:
cal- the Calendar instance to get the ISO8601 formatted string for- Returns:
- a ISO8601 formatted string for the provided Calendar instance, or null if call is null
-
toString
public static java.lang.String toString(java.util.Date date, boolean withMsec)Get a ISO8601 formatted string for the provided Date instance.- Parameters:
date- the Date instance to get the ISO8601 formatted string forwithMsec- flag indicating whether to include milliseconds- Returns:
- a ISO8601 formatted string for the provided Date instance, or null if date is null
-
dateOnly
public static java.lang.String dateOnly(java.util.Date date)
Get a string that includes the date only in yyyy-mm-ss format.- Parameters:
date- the Date instance to get the date only formatted string for- Returns:
- a string that includes the date only in yyyy-mm-ss format, or null if date is null
-
toString
public static java.lang.String toString(java.util.Date date)
Get a ISO8601 formatted string for the provided Date instance.- Parameters:
date- the Date instance to get the ISO8601 formatted string for- Returns:
- a ISO8601 formatted string for the provided Date instance, or null if date is null
-
toInstant
public static java.time.Instant toInstant(java.lang.String dateTimeString) throws java.text.ParseExceptionParses an ISO8601 formatted string a returns an Instant instance.- Parameters:
dateTimeString- the ISO8601 formatted string- Returns:
- an Instant instance for the ISO8601 formatted string
- Throws:
java.text.ParseException- if the provided string is not in the proper format
-
toDate
public static java.util.Date toDate(java.lang.String dateTimeString) throws java.text.ParseExceptionParses an ISO8601 formatted string a returns a Date instance.- Parameters:
dateTimeString- the ISO8601 formatted string- Returns:
- a Date instance for the ISO8601 formatted string
- Throws:
java.text.ParseException- if the provided string is not in the proper format
-
toCalendar
public static java.util.Calendar toCalendar(java.lang.String dateTimeString) throws java.text.ParseExceptionParses an ISO8601 formatted string a returns a Calendar instance.- Parameters:
dateTimeString- the ISO8601 formatted string- Returns:
- a Calendar instance for the ISO8601 formatted string
- Throws:
java.text.ParseException- if the provided string is not in the proper format
-
-