Created
March 21, 2020 07:15
-
-
Save wfng92/1d27eefd3acaf6eeef9dc46226a04574 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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