Class DockerDateFormat

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public class DockerDateFormat
    extends com.fasterxml.jackson.databind.util.StdDateFormat
    Docker returns timestamps with nanosecond precision (e.g. 2014-10-17T21:22:56.949763914Z), but 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.

    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.text.DateFormat

        java.text.DateFormat.Field
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static long serialVersionUID  
      private static java.lang.String TIMEZONE_PATTERN  
      • Fields inherited from class com.fasterxml.jackson.databind.util.StdDateFormat

        _lenient, _locale, _timezone, ALL_FORMATS, CALENDAR, 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
      • Fields inherited from class java.text.DateFormat

        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
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      DockerDateFormat clone()  
      java.util.Date parse​(java.lang.String source)  
      • Methods inherited from class com.fasterxml.jackson.databind.util.StdDateFormat

        _clearFormats, _equals, _format, _formatBCEYear, _getCalendar, _parseAsISO8601, _parseDate, equals, format, getDefaultTimeZone, getISO8601Format, getRFC1123Format, getTimeZone, hashCode, isColonIncludedInTimeZone, isLenient, looksLikeISO8601, parse, parseAsISO8601, parseAsRFC1123, setLenient, setTimeZone, toPattern, toString, withColonInTimeZone, withLenient, withLocale, withTimeZone
      • Methods inherited from class java.text.DateFormat

        format, format, getAvailableLocales, getCalendar, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getNumberFormat, getTimeInstance, getTimeInstance, getTimeInstance, parseObject, setCalendar, setNumberFormat
      • Methods inherited from class java.text.Format

        format, formatToCharacterIterator, parseObject
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • DockerDateFormat

        public DockerDateFormat()
    • Method Detail

      • parse

        public java.util.Date parse​(java.lang.String source)
                             throws java.text.ParseException
        Overrides:
        parse in class com.fasterxml.jackson.databind.util.StdDateFormat
        Throws:
        java.text.ParseException
      • clone

        public DockerDateFormat clone()
        Overrides:
        clone in class com.fasterxml.jackson.databind.util.StdDateFormat