Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
njimenezotto opened this issue Sep 12, 2024 · 0 comments
Open

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

njimenezotto opened this issue Sep 12, 2024 · 0 comments

Comments

@njimenezotto
Copy link

njimenezotto commented Sep 12, 2024

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.

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

No branches or pull requests

1 participant