当我使用User类时,用户名和密码将保存在Cloud Firestore中,但时间戳为null。任何人都可以帮助解决此问题。
public class AccountFragment extends Fragment {
Timestamp timestamp;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final User user = new User(timestamp);
公共类用户{
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;
}
}
请帮助。
答案 0 :(得分:0)
是的,我找到了解决方案。其实我忘了初始化它。在下面添加行后,我的问题解决了。
timestamp = Timestamp.now();