Package org.gitlab4j.api.utils
Class ISO8601
java.lang.Object
org.gitlab4j.api.utils.ISO8601
public class ISO8601 extends Object
This class provides utility methods for parsing and formatting ISO8601 formatted dates.
-
Field Summary
Fields Modifier and Type Field Description static StringDATE_ONLY_PATTERNstatic StringMSEC_PATTERNstatic StringOUTPUT_MSEC_PATTERNstatic StringOUTPUT_PATTERNstatic StringPATTERNstatic StringPATTERN_MSECstatic StringSPACEY_MSEC_PATTERNstatic StringSPACEY_PATTERNstatic StringUTC_PATTERN -
Constructor Summary
Constructors Constructor Description ISO8601() -
Method Summary
Modifier and Type Method Description static StringdateOnly(Date date)Get a string that includes the date only in yyyy-mm-ss format.static StringgetTimestamp()Get a ISO8601 formatted string for the current date and time.static StringgetTimestamp(boolean withMsec)Get a ISO8601formatted string for the current date and time.static CalendartoCalendar(String dateTimeString)Parses an ISO8601 formatted string a returns a Calendar instance.static DatetoDate(String dateTimeString)Parses an ISO8601 formatted string a returns a Date instance.static InstanttoInstant(String dateTimeString)Parses an ISO8601 formatted string a returns an Instant instance.static StringtoString(Calendar cal)Get a ISO8601 formatted string for the provided Calendar instance.static StringtoString(Date date)Get a ISO8601 formatted string for the provided Date instance.static StringtoString(Date date, boolean withMsec)Get a ISO8601 formatted string for the provided Date instance.
-
Field Details
-
PATTERN
- See Also:
- Constant Field Values
-
MSEC_PATTERN
- See Also:
- Constant Field Values
-
SPACEY_PATTERN
- See Also:
- Constant Field Values
-
SPACEY_MSEC_PATTERN
- See Also:
- Constant Field Values
-
PATTERN_MSEC
- See Also:
- Constant Field Values
-
OUTPUT_PATTERN
- See Also:
- Constant Field Values
-
OUTPUT_MSEC_PATTERN
- See Also:
- Constant Field Values
-
UTC_PATTERN
- See Also:
- Constant Field Values
-
DATE_ONLY_PATTERN
- See Also:
- Constant Field Values
-
-
Constructor Details
-
ISO8601
public ISO8601()
-
-
Method Details
-
getTimestamp
Get a ISO8601 formatted string for the current date and time.- Returns:
- a ISO8601 formatted string for the current date and time
-
getTimestamp
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
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
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
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
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
Parses 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:
ParseException- if the provided string is not in the proper format
-
toDate
Parses 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:
ParseException- if the provided string is not in the proper format
-
toCalendar
Parses 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:
ParseException- if the provided string is not in the proper format
-