public class DockerDateFormat
extends com.fasterxml.jackson.databind.util.StdDateFormat
Date
only supports milliseconds. Creating a Date from the nanosecond timestamp
results in the date being set to several days after what date should be. This class converts the
timestamp from nanoseconds to milliseconds by removing the last six digits of the timestamp, so
we can generate a Date with the correct value (albeit with less precision).
Note: a more complete solution would be to introduce a custom date type which can store the nanosecond value in an additional field, so users can access the complete value. Or just use Java 8 which has date objects with nanosecond support.
DateFormat.Field
_lenient, _locale, _timezone, ALL_FORMATS, CALENDAR, DATE_FORMAT_ISO8601, DATE_FORMAT_RFC1123, DATE_FORMAT_STR_ISO8601, DATE_FORMAT_STR_PLAIN, DATE_FORMAT_STR_RFC1123, DEFAULT_LOCALE, DEFAULT_TIMEZONE, instance, PATTERN_ISO8601, PATTERN_PLAIN, PATTERN_PLAIN_STR
AM_PM_FIELD, calendar, DATE_FIELD, DAY_OF_WEEK_FIELD, DAY_OF_WEEK_IN_MONTH_FIELD, DAY_OF_YEAR_FIELD, DEFAULT, ERA_FIELD, FULL, HOUR_OF_DAY0_FIELD, HOUR_OF_DAY1_FIELD, HOUR0_FIELD, HOUR1_FIELD, LONG, MEDIUM, MILLISECOND_FIELD, MINUTE_FIELD, MONTH_FIELD, numberFormat, SECOND_FIELD, SHORT, TIMEZONE_FIELD, WEEK_OF_MONTH_FIELD, WEEK_OF_YEAR_FIELD, YEAR_FIELD
Constructor and Description |
---|
DockerDateFormat() |
Modifier and Type | Method and Description |
---|---|
DockerDateFormat |
clone() |
Date |
parse(String source) |
_clearFormats, _equals, _format, _getCalendar, _parseAsISO8601, _parseDate, equals, format, getDefaultTimeZone, getISO8601Format, getRFC1123Format, getTimeZone, hashCode, isColonIncludedInTimeZone, isLenient, looksLikeISO8601, parse, parseAsISO8601, parseAsRFC1123, setLenient, setTimeZone, toPattern, toString, withColonInTimeZone, withLenient, withLocale, withTimeZone
format, format, getAvailableLocales, getCalendar, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getNumberFormat, getTimeInstance, getTimeInstance, getTimeInstance, parseObject, setCalendar, setNumberFormat
format, formatToCharacterIterator, parseObject
public Date parse(String source) throws ParseException
parse
in class com.fasterxml.jackson.databind.util.StdDateFormat
ParseException
public DockerDateFormat clone()
clone
in class com.fasterxml.jackson.databind.util.StdDateFormat
Copyright © 2018. All rights reserved.