public class ISO8601 extends Object
Modifier and Type | Field and Description |
---|---|
static String |
OUTPUT_MSEC_PATTERN |
static String |
OUTPUT_PATTERN |
static String |
PATTERN |
static String |
PATTERN_MSEC |
static String |
UTC_PATTERN |
Constructor and Description |
---|
ISO8601() |
Modifier and Type | Method and Description |
---|---|
static String |
getTimestamp()
Get a ISO8601 formatted string for the current date and time.
|
static String |
getTimestamp(boolean withMsec)
Get a ISO8601formatted string for the current date and time.
|
static Calendar |
toCalendar(String dateTimeString)
Parses an ISO8601 formatted string a returns a Calendar instance.
|
static Date |
toDate(String dateTimeString)
Parses an ISO8601 formatted string a returns a Date instance.
|
static String |
toString(Calendar cal)
Get a ISO8601 formatted string for the provided Calendar instance.
|
static String |
toString(Date date)
Get a ISO8601 formatted string for the provided Date instance.
|
static String |
toString(Date date,
boolean withMsec)
Get a ISO8601 formatted string for the provided Date instance.
|
public static final String PATTERN
public static final String PATTERN_MSEC
public static final String OUTPUT_PATTERN
public static final String OUTPUT_MSEC_PATTERN
public static final String UTC_PATTERN
public static String getTimestamp()
public static String getTimestamp(boolean withMsec)
withMsec
- flag indicating whether to include millisecondspublic static String toString(Calendar cal)
cal
- the Calendar instance to get the ISO8601 formatted string forpublic static String toString(Date date, boolean withMsec)
date
- the Date instance to get the ISO8601 formatted string forwithMsec
- flag indicating whether to include millisecondspublic static String toString(Date date)
date
- the Date instance to get the ISO8601 formatted string forpublic static Date toDate(String dateTimeString) throws ParseException
dateTimeString
- the ISO8601 formatted stringParseException
- if the provided string is not in the proper formatpublic static Calendar toCalendar(String dateTimeString) throws ParseException
dateTimeString
- the ISO8601 formatted stringParseException
- if the provided string is not in the proper formatCopyright © 2018. All rights reserved.