Skip to content

Default Date encoder doesn't preserve milliseconds #43

Open
@BrunoBonacci

Description

Hi,

I've noticed that the default encoder for dates doesn't preserve the milliseconds precision

  ;; milliseconds are truncated
  (json/write-value-as-string {:date (java.util.Date.)})
  ;;=> "{\"date\":\"2021-01-12T10:19:44Z\"}"

  (json/write-value-as-string {:date (java.util.Date.)}
    (json/object-mapper {:date-format "yyyy-MM-dd'T'HH:mm:ss.SSSX"}))
  ;;=> "{\"date\":\"2021-01-12T10:19:44.596Z\"}"

Is this a deliberate decision? wouldn't be better for the default encoder to preserve data as much as possible rather than truncating it?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions