[firestore][android] Correctly process date time zones

This commit is contained in:
Chris Bianca 2017-10-18 14:29:37 +01:00
parent bc1e827273
commit fc3fc6d0d2
2 changed files with 4 additions and 2 deletions

View File

@ -30,7 +30,7 @@ import io.invertase.firebase.Utils;
public class FirestoreSerialize {
private static final String TAG = "FirestoreSerialize";
private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX");
private static final String KEY_CHANGES = "changes";
private static final String KEY_DATA = "data";
private static final String KEY_DOC_CHANGE_DOCUMENT = "document";

View File

@ -426,13 +426,15 @@ function documentReferenceTests({ describe, it, context, firebase }) {
context('types', () => {
it('should handle Date field', async () => {
const date = new Date();
const docRef = firebase.native.firestore().doc('document-tests/reference');
await docRef.set({
field: new Date(),
field: date,
});
const doc = await docRef.get();
doc.data().field.should.be.instanceof(Date);
should.equal(doc.data().field.toISOString(), date.toISOString());
});
});