Skip to content

Change default of SerializationFeature.WRITE_DATES_AS_TIMESTAMPS to false in 3.0Β #4845

Closed

Description

@cowtowncoder

(note: part of proposed changes via https://github.com/FasterXML/jackson-future-ideas/wiki/JSTEP-2)

It seems that the default of writing basic Date/Time values as numeric timestamps is something that should be changed: while this is more efficient than the alternative of writing Date/Time value as Strings, most users expect Strings, and most frameworks seem to change the default.

So the proposal is to change the default accordingly.

Activity

  1. cowtowncoder commented on Jan 30, 2025

    @cowtowncoder
    MemberAuthor

    Change has been approved: we can proceed with change!

  2. added a commit that references this issue on Feb 1, 2025
  3. added a commit that references this issue on Feb 5, 2025
    961c128
  4. cowtowncoder commented on Feb 7, 2025

    @cowtowncoder
    MemberAuthor

    Defaults have been changed for 3.0.0-rc1.

  5. soc commented on Jul 22, 2026

    @soc

    Is there some place that explicitly lists which date/time classes from the JDK are affected, and how?

    I went through various pages linked from this discussion, but could not find anything definitive.

  6. pjfanning commented on Jul 22, 2026

    @pjfanning
    Member

    @soc this is configurable. If you don't like the setting default, you can change it.

  7. soc commented on Jul 22, 2026

    @soc

    Both liking/disliking as well as configuring a setting requires understanding what the setting does, which is the exact topic of my original question.

  8. pjfanning commented on Jul 22, 2026

    @pjfanning
    Member

    and long closed issues are not the place to suddenly start a discussion. Open a GitHub discussion.

  9. soc commented on Jul 22, 2026

    @soc

    What discussion?

  10. pjfanning commented on Jul 22, 2026

    @pjfanning
    Member
  11. pjfanning commented on Jul 22, 2026

    @pjfanning
    Member

    The Javadoc on these feature is quite detailed. I don't see how we could be much more specific.

    * Feature that determines whether Date (and date/time) values
    * (and Date-based things like {@link java.util.Calendar}s) are to be
    * serialized as numeric time stamps ({@code true}),
    * or as textual representation ({@code false}).
    * If textual representation is used, the actual format depends on configuration
    * settings including global defaults and possible per-type and/or per-property
    * {@code @JsonFormat} annotation overrides.
    *<p>
    * For "classic" JDK date types ({@link java.util.Date}, {@link java.util.Calendar})
    * the default formatting is provided by {@link tools.jackson.databind.util.StdDateFormat},
    * and corresponds to format String of "yyyy-MM-dd'T'HH:mm:ss.SSSX"
    * (see {@link java.text.DateFormat} for details of format Strings).
    * For Java 8 ({@code java.time.*}) and Joda Date-time textual format
    * configuration differs, but this feature is still used as global
    * default when choosing between numeric time stamps and textual representation.
    *<p>
    * Note: whether {@link java.util.Map} keys are serialized as Strings
    * or not is controlled using {@link #WRITE_DATE_KEYS_AS_TIMESTAMPS} instead of
    * this feature.
    *<p>
    * Feature used to be one of {@link tools.jackson.databind.SerializationFeature}s
    * in Jackson 2.x but was moved here in 3.0.
    *<p>
    * Feature is disabled by default as of Jackson 3.0 (in 2.x it was enabled),
    * so that date/time are by default serialized as textual values NOT timestamps.

  12. soc commented on Jul 22, 2026

    @soc

    Jackson 3:

     WRITE_DATES_AS_TIMESTAMPS   |          true          |          false
    ---------------------------------------------------------------------------------------
     java.util.Date              | "1596105045000"        | "\"2020-07-30T10:30:45.000Z\""
     java.util.GregorianCalendar | "1596105045000"        | "\"2020-07-30T10:30:45.000Z\""
     java.time.Instant           | "1596112245.000000000" | "\"2020-07-30T12:30:45Z\""
     java.time.LocalDateTime     | "[2020,7,30,12,30,45]" | "\"2020-07-30T12:30:45\""
     etc.
    

    Jackson 2:

     WRITE_DATES_AS_TIMESTAMPS   |          true          |          false
    ---------------------------------------------------------------------------------------
     java.util.Date              | "1596105045000"        | "\"2020-07-30T10:30:45.000+00:00\""
     java.util.GregorianCalendar | "1596105045000"        | "\"2020-07-30T10:30:45.000+00:00\""
     java.time.Instant           | "1596112245.000000000" | "\"2020-07-30T12:30:45Z\""
     java.time.LocalDateTime     | "[2020,7,30,12,30,45]" | "\"2020-07-30T12:30:45\""
     etc.
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.0Issue planned for initial 3.0 release3.0-release-notesIssues relevant for 3.0 release notes.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions