Skip to content

NPE trying to convert Epoch date 1970-01-01 to Timestamp #450

@njimenezotto

Description

@njimenezotto

The following case throws a NPE

Date defaultEpochDate = new Date(0);
mapToTimestamp(defaultEpochDate.toInstant())

The problem is for this case EpochSecond and Nano are 0 and this builder does not allow it.

Timestamp t = Timestamp.newBuilder().setSeconds(i.getEpochSecond()).setNanos(i.getNano()).build();

I think the solution could be to handle the 0 seconds case and use the Timestamp.getDefaultInstance() instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions