Skip to content

Manish Kashyap

My feedback

1 result found

  1. 9 votes

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    How important is this to you?

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    An error occurred while saving the comment
    Manish Kashyap commented  · 

    As per the link below these are stored with millisecond precision
    https://www.mongodb.com/docs/manual/reference/bson-types/#std-label-document-bson-type-date
    BSON Date is a 64-bit integer that represents the number of milliseconds since the Unix epoch (Jan 1, 1970). This results in a representable date range of about 290 million years into the past and future.

    However for java.time.LocalDateTime , it is stored to nano second precision.
    https://docs.oracle.com/javase/8/docs/api/java/time/LocalDateTime.html

    Time is represented to nanosecond precision. For example, the value "2nd October 2007 at 13:45.30.123456789" can be stored in a LocalDateTime.

    Therefore we are not able to store the LocalDateTime as BSON Date type in Mongo and therefore we can not query using the LocalDateTime.

    The current workaround which we currently doing is to store them as String and deserialising them as LocalDateTime, however we can not query using the LocalDateTime.

    Manish Kashyap supported this idea  · 

Feedback and Knowledge Base