async-datastore-client icon indicating copy to clipboard operation
async-datastore-client copied to clipboard

Unable to persist dates before January 1st 1970

Open etibarhasanov opened this issue 7 years ago • 0 comments

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.

etibarhasanov avatar Dec 12 '18 13:12 etibarhasanov