Skip to content

Conversation

eranl
Copy link
Contributor

@eranl eranl commented Sep 7, 2024

Add support for java.time.Instant as a timestamp type.
This is a port of googleapis/java-firestore#1586.

@eranl
Copy link
Contributor Author

eranl commented Apr 16, 2025

Following up. @tom-andersen, I just realized you requested that I tag you here.

@tom-andersen tom-andersen self-assigned this Apr 18, 2025
@eranl
Copy link
Contributor Author

eranl commented Apr 18, 2025

@tom-andersen, the latest test failures seem to be unrelated to my change, and this branch is fully caught-up.

@tom-andersen
Copy link
Contributor

tom-andersen commented Apr 22, 2025

Thanks! I will copy the branch over to make the CI run properly.

I will also need to understand how this is backward compatible.

@eranl
Copy link
Contributor Author

eranl commented Apr 22, 2025

Thanks! I will copy the branch over to make the CI run properly.

Thanks.

I will also need to understand how this is backward compatible.

The same way googleapis/java-firestore#1586 was.

@dconeybe
Copy link
Contributor

Consider adding support for kotlinx.datetime.Instant as well.

https://kotlinlang.org/api/kotlinx-datetime/kotlinx-datetime/kotlinx.datetime/-instant/

@eranl
Copy link
Contributor Author

eranl commented Apr 24, 2025

Consider adding support for kotlinx.datetime.Instant as well.

Done. Also added tests.

Copy link
Contributor

@dconeybe dconeybe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Thank you for this contribution!

@eranl
Copy link
Contributor Author

eranl commented Oct 1, 2025

I don't follow the check failures...

@dconeybe
Copy link
Contributor

dconeybe commented Oct 1, 2025

I don't follow the check failures...

Ahh yes, don't worry about those. Those checks are broken on external PRs.

But that does remind me... can you add an entry to the "Unreleased" section of firebase-firestore/CHANGELOG.md:

- [changed] Add `java.time.Instant` support to `DocumentSnapshot.toObject()`,
  `DocumentReference.set()`, `DocumentReference.update()`, and similar.
  [#6235](//github.com/firebase/firebase-android-sdk/pull/6235)

@eranl
Copy link
Contributor Author

eranl commented Oct 1, 2025

Done.

@dconeybe dconeybe self-assigned this Oct 1, 2025
@dconeybe dconeybe merged commit 8a8298d into firebase:main Oct 2, 2025
21 of 23 checks passed
@dconeybe dconeybe changed the title feat: Instant support firestore: Instant support Oct 2, 2025
dconeybe added a commit that referenced this pull request Oct 3, 2025
…roken by #6235

The test failure fixed by this PR is:

```
com.google.firebase.firestore.ServerTimestampTest > testPOJOWithWrongType[emulator-5554 - 12] FAILED
	org.junit.ComparisonFailure: expected:<...ring instead of Date[ or Timestamp].> but was:<...ring instead of Date[, Timestamp, or Instant].>
	at org.junit.Assert.assertEquals(Assert.java:117)
```

It simply updates the expected exception message as follows:

```
- "java.lang.String instead of Date or Timestamp.",
+ "java.lang.String instead of Date, Timestamp, or Instant.",
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants