Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Unable to persist dates before January 1st 1970 #29

Open
etibarhasanov opened this issue Dec 12, 2018 · 0 comments
Open

Unable to persist dates before January 1st 1970 #29

etibarhasanov opened this issue Dec 12, 2018 · 0 comments

Comments

@etibarhasanov
Copy link

etibarhasanov commented Dec 12, 2018

Dates values are currently handled in the following fashion:

  private  static Timestamp toTimestamp(Date date) {
    final long millis = date.getTime();
    return Timestamp
        .newBuilder()
        .setSeconds(millis / 1000)
        .setNanos((int) ((millis % 1000) * 1000000))
        .build();
  }

This results in the nanosecond value being a negative number if the supplied date is earlier than January 1st 1970.

However, according to Protobuf documentation, the accepted values are from 0 to 999,999,999 inclusive.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant