1//Table names in SQLite are case insensitive.
2@Entity(indices = {@Index(value = "first_name")})
3public class User {
4 @PrimaryKey(autoGenerate = true)
5 @ColumnInfo(name = "user_id")
6 public long userId;
7 @ColumnInfo(name = "first_name")
8 public String firstName;
9 @ColumnInfo(name = "created_date")
10 @TypeConverters({TimestampConverter.class})
11 public Date createDate;
12 @ColumnInfo(name = "date_of_birth")
13 @TypeConverters({DateConverter.class})
14 public Date dob;
15 @Embedded
16 public Address address;
17}
1public class TimestampConverter {
2 static DateFormat df = new SimpleDateFormat(Constants.TIME_STAMP_FORMAT);
3 @TypeConverter
4 public static Date fromTimestamp(String value) {
5 if (value != null) {
6 try {
7 return df.parse(value);
8 } catch (ParseException e) {
9 e.printStackTrace();
10 }
11 return null;
12 } else {
13 return null;
14 }
15 }