public class ISO8601
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DATE_ONLY_PATTERN |
static java.lang.String |
MSEC_PATTERN |
static java.lang.String |
OUTPUT_MSEC_PATTERN |
static java.lang.String |
OUTPUT_PATTERN |
static java.lang.String |
PATTERN |
static java.lang.String |
PATTERN_MSEC |
static java.lang.String |
SPACEY_MSEC_PATTERN |
static java.lang.String |
SPACEY_PATTERN |
static java.lang.String |
UTC_PATTERN |
Constructor and Description |
---|
ISO8601() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
dateOnly(java.util.Date date)
Get a string that includes the date only in yyyy-mm-ss format.
|
static java.lang.String |
getTimestamp()
Get a ISO8601 formatted string for the current date and time.
|
static java.lang.String |
getTimestamp(boolean withMsec)
Get a ISO8601formatted string for the current date and time.
|
static java.util.Calendar |
toCalendar(java.lang.String dateTimeString)
Parses an ISO8601 formatted string a returns a Calendar instance.
|
static java.util.Date |
toDate(java.lang.String dateTimeString)
Parses an ISO8601 formatted string a returns a Date instance.
|
static java.time.Instant |
toInstant(java.lang.String dateTimeString)
Parses an ISO8601 formatted string a returns an Instant instance.
|
static java.lang.String |
toString(java.util.Calendar cal)
Get a ISO8601 formatted string for the provided Calendar instance.
|
static java.lang.String |
toString(java.util.Date date)
Get a ISO8601 formatted string for the provided Date instance.
|
static java.lang.String |
toString(java.util.Date date,
boolean withMsec)
Get a ISO8601 formatted string for the provided Date instance.
|
public static final java.lang.String PATTERN
public static final java.lang.String MSEC_PATTERN
public static final java.lang.String SPACEY_PATTERN
public static final java.lang.String SPACEY_MSEC_PATTERN
public static final java.lang.String PATTERN_MSEC
public static final java.lang.String OUTPUT_PATTERN
public static final java.lang.String OUTPUT_MSEC_PATTERN
public static final java.lang.String UTC_PATTERN
public static final java.lang.String DATE_ONLY_PATTERN
public static java.lang.String getTimestamp()
public static java.lang.String getTimestamp(boolean withMsec)
withMsec
- flag indicating whether to include millisecondspublic static java.lang.String toString(java.util.Calendar cal)
cal
- the Calendar instance to get the ISO8601 formatted string forpublic static java.lang.String toString(java.util.Date date, boolean withMsec)
date
- the Date instance to get the ISO8601 formatted string forwithMsec
- flag indicating whether to include millisecondspublic static java.lang.String dateOnly(java.util.Date date)
date
- the Date instance to get the date only formatted string forpublic static java.lang.String toString(java.util.Date date)
date
- the Date instance to get the ISO8601 formatted string forpublic static java.time.Instant toInstant(java.lang.String dateTimeString) throws java.text.ParseException
dateTimeString
- the ISO8601 formatted stringjava.text.ParseException
- if the provided string is not in the proper formatpublic static java.util.Date toDate(java.lang.String dateTimeString) throws java.text.ParseException
dateTimeString
- the ISO8601 formatted stringjava.text.ParseException
- if the provided string is not in the proper formatpublic static java.util.Calendar toCalendar(java.lang.String dateTimeString) throws java.text.ParseException
dateTimeString
- the ISO8601 formatted stringjava.text.ParseException
- if the provided string is not in the proper format