Skip to content

Instantly share code, notes, and snippets.

@wfng92
Created March 21, 2020 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wfng92/1d27eefd3acaf6eeef9dc46226a04574 to your computer and use it in GitHub Desktop.
Save wfng92/1d27eefd3acaf6eeef9dc46226a04574 to your computer and use it in GitHub Desktop.
import java.text.SimpleDateFormat;
import java.util.Date;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
@Entity
public class User {
public User() {
}
public User(long timestamp, String name) {
this.timestamp = timestamp;
this.name = name;
}
@PrimaryKey(autoGenerate = true)
public int uid;
@ColumnInfo(name = "timestamp")
public long timestamp;
@ColumnInfo(name = "name")
public String name;
public String getDateString() {
SimpleDateFormat sdf = new SimpleDateFormat();
sdf.applyPattern("yyyy-MM-dd HH:mm:ss a");
return sdf.format(new Date(timestamp));
}
public String getDebugString() {
return "UID: " + uid + " Timestamp: " + getDateString() + " Name: " + name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment