public class UtcTimestampConverter extends Object
Constructor and Description |
---|
UtcTimestampConverter() |
Modifier and Type | Method and Description |
---|---|
protected static void |
assertDigitSequence(String value,
int i,
int j,
String type) |
protected static void |
assertLength(String value,
int i,
String type) |
protected static void |
assertLength(String value,
String type,
int... lengths) |
protected static void |
assertSeparator(String value,
int offset,
char ch,
String type) |
static String |
convert(Date d,
boolean includeMilliseconds)
Convert a timestamp (represented as a Date) to a String.
|
static String |
convert(LocalDateTime d,
UtcTimestampPrecision precision)
Convert a timestamp (represented as a LocalDateTime) to a String.
|
static Date |
convert(String value)
Convert a timestamp string into a Date.
|
static LocalDateTime |
convertToLocalDateTime(String value)
Convert a timestamp string into a LocalDateTime object.
|
protected DateFormat |
createDateFormat(String format) |
protected static DateTimeFormatter |
createDateTimeFormat(String format) |
static Date |
getDate(LocalDateTime localDateTime) |
protected static long |
parseLong(String s) |
protected static void |
throwFieldConvertError(String value,
String type) |
public static String convert(Date d, boolean includeMilliseconds)
d
- the date to convertincludeMilliseconds
- controls whether milliseconds are included in
the resultpublic static String convert(LocalDateTime d, UtcTimestampPrecision precision)
d
- the date to convertprecision
- controls whether seconds, milliseconds, microseconds or
nanoseconds are included in the resultpublic static Date convert(String value) throws FieldConvertError
value
- the timestamp StringFieldConvertError
- raised if timestamp is an incorrect format.public static LocalDateTime convertToLocalDateTime(String value) throws FieldConvertError
value
- the timestamp StringFieldConvertError
- raised if timestamp is an incorrect format.public static Date getDate(LocalDateTime localDateTime)
localDateTime
- protected static void assertLength(String value, int i, String type) throws FieldConvertError
FieldConvertError
protected static void assertLength(String value, String type, int... lengths) throws FieldConvertError
FieldConvertError
protected static void assertDigitSequence(String value, int i, int j, String type) throws FieldConvertError
FieldConvertError
protected static void assertSeparator(String value, int offset, char ch, String type) throws FieldConvertError
FieldConvertError
protected static void throwFieldConvertError(String value, String type) throws FieldConvertError
FieldConvertError
protected static long parseLong(String s)
protected DateFormat createDateFormat(String format)
protected static DateTimeFormatter createDateTimeFormat(String format)
Copyright © 2021. All rights reserved.