Class DockerDateFormat

java.lang.Object
java.text.Format
java.text.DateFormat
com.fasterxml.jackson.databind.util.StdDateFormat
com.spotify.docker.client.DockerDateFormat
All Implemented Interfaces:
Serializable, 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:
  • Field Details

  • Constructor Details

    • DockerDateFormat

      public DockerDateFormat()
  • Method Details

    • parse

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

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