Skip to content

Add class that handles ServerValue #335

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

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions database/src/main/java/com/firebase/ui/database/Timestamp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.firebase.ui.database;

import com.google.firebase.database.Exclude;
import com.google.firebase.database.PropertyName;
import com.google.firebase.database.ServerValue;

import java.util.Map;

public class Timestamp {
private long mTimestamp;

@PropertyName("timestamp")
protected Map<String, String> getServerValue() {
return ServerValue.TIMESTAMP;
}

@Exclude
public long getTimestamp() {
return mTimestamp;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should I check to see if mTimestamp is 0 (null) here? If so, I would return the system time. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we'd want to return system time, that's not the same as unset. I prefer how it is now, it's the least opinionated and most likely to solve the original problem (serialization/deserialization of time stamps is annoying)


protected void setTimestamp(long time) {
mTimestamp = time;
}
}