Sabir Syed
Sabir Syed

Reputation: 442

timestamp is null after using below object

When I use the User class, user name and password is getting saved in cloud firestore, but timestamp is null. Anyone can help on resolving this issue.

public class AccountFragment extends Fragment {

Timestamp timestamp;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

final User user = new User(timestamp);

public class User {

private String username;
private String password;
Timestamp timestamp;

public User() {
}

public User(String username, String password, Timestamp timestamp) {
    this.username = username;
    this.password = password;
    this.timestamp = timestamp;
}

public String getUsername() {
    return username;
}

public void setUsername(String username) {
    this.username = username;
}

public String getPassword() {
    return password;
}

public void setPassword(String password) {
    this.password = password;
}

public Timestamp getTimestamp() {
    return timestamp;
}

public void setTimestamp(Timestamp timestamp) {
    this.timestamp = timestamp;
}

}

Please help.

Upvotes: 1

Views: 72

Answers (1)

Sabir Syed
Sabir Syed

Reputation: 442

Yes, I got the solution. Actually, I forgot to initialize it. After adding the below line my problem resolved.

timestamp = Timestamp.now();

Upvotes: 1

Related Questions