Skip to content

Follow-up to #8158: DATETIME_SECOND read back with dateTimeImplementation set to java.util.Date or java.util.Calendar is 1000 times too small, silently #8253

Closed

Description

@ruispereira

Summary

Follow-up to #8158. That issue was about DATETIME_MICROS and DATETIME_NANOS reading back as null when arcadedb.dateTimeImplementation is java.util.Date or java.util.Calendar, and the fix gave those two types a LocalDateTime fallback. DATETIME_SECOND is the fourth arm of the same switch and still passes dateTimeImplementation straight through.

A DATETIME_SECOND column stores epoch SECONDS. The read hands that number to DateUtils.dateTime(..., SECONDS, dateTimeImplementation, SECONDS); convertTimestamp() returns it unchanged because from == to, and the number is then fed to new Date(ms) and Calendar.setTimeInMillis(ms). Both accept it, so nothing throws and the corrupt-property recovery never fires: the read simply answers a timestamp 1000 times too small.

That is worse than the symptom #8158 reported. A null is visible; a plausible wrong date is not.

Where (HEAD 6fefb26)

engine/src/main/java/com/arcadedb/serializer/BinarySerializer.java:847-850, the one arm of the switch still using the raw setting:

    case BinaryTypes.TYPE_DATETIME_SECOND:
      value = DateUtils.dateTime(database, content.getUnsignedNumber(), ChronoUnit.SECONDS, dateTimeImplementation,
          ChronoUnit.SECONDS);

reaching engine/src/main/java/com/arcadedb/utility/DateUtils.java:114 and :120:

    if (dateTimeImplementation.equals(Date.class)) {
      ...
      value = new Date(convertedTimestamp);
    } else if (dateTimeImplementation.equals(Calendar.class)) {
      ...
      ((Calendar) value).setTimeInMillis(convertedTimestamp);

convertedTimestamp is still in seconds here: convertTimestamp() returns its input unchanged when from == to (DateUtils.java:800).

Repro

One record with a DATETIME_SECOND property dts stored as 2024-02-29 13:45:10, read back under each configured implementation:

  LocalDateTime impl: dts=2024-02-29T13:45:10          (correct)
  Date impl:          dts=Tue Jan 20 19:46:54 WET 1970 (WRONG - 1709214310 read as MILLIS)
  Calendar impl:      dts=GregorianCalendar[time=1709214310, YEAR=1970, MONTH=0, DAY_OF_MONTH=20, ...] (WRONG)
  ZonedDateTime impl: dts=2024-02-29T13:45:10Z[UTC]    (correct)
  Instant impl:       dts=2024-02-29T13:45:10Z         (correct)

No exception and no "Skipping corrupted property" warning in the two wrong cases.

Suggested fix

Give DATETIME_SECOND the same treatment #8158 gave DATETIME_MICROS and DATETIME_NANOS: resolve the implementation through the new subMillisDateTimeImplementation field, or convert seconds to milliseconds before handing the value to Date/Calendar. The first keeps the four arms consistent.

Scope / confidence

Measured on a build of today's HEAD, in the same run that confirmed the #8158 fix works for MICROS and NANOS. Pre-existing rather than introduced, but it is the identical sibling site in the same switch that the fix walked past, and it leaves DATETIME_SECOND as the only one of the four datetime types whose answer depends on the configured implementation.

Swept while checking: getDateTimeImplementation() callers outside the serializer are consistent with the new behaviour. RemoteImmutableDocument.java:74 and :214 already apply the setting only to Type.DATETIME and fall back to propType.getDefaultJavaType() for the sub-millisecond types, so the remote client agrees. SQLMethodAsDateTime.java:53, SQLFunctionSysdate and SQLFunctionDate go through DateUtils.getDate(), which takes no precision argument. Only Date.class and Calendar.class exactly can reach these arms, since DateUtils dispatches with .equals and anything else falls to a SerializationException, so there is no subclass gap.

Activity

  1. added
    engine
    severity:major
    on Sep 23, 2026
  2. added this to the 26.10.1 milestone on Sep 23, 2026
  3. added
    in progress
    on Sep 24, 2026
  4. self-assigned this
    on Sep 24, 2026
  5. added a commit that references this issue on Sep 25, 2026
  6. lvca commented on Sep 25, 2026

    @lvca
    Member

    Fixed in #8309, available in 26.10.1.

    A DATETIME_SECOND property read back with arcadedb.dateTimeImplementation set to java.util.Date or java.util.Calendar is now converted from seconds to milliseconds first, so it returns the correct date instead of one in January 1970.


    ❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.

  7. removed
    in progress
    on Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugengineseverity:major

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions