Mohd Faisal
07/27/2026, 11:04 AMLong (epoch milliseconds or epoch days)
• Date
• LocalDate (with a TypeConverter)
• Something else?
My current attendance model is roughly:
@Entity
data class AttendanceEntity(
@PrimaryKey(autoGenerate = true)
val id: Long = 0,
val studentId: Long,
val attendanceDate: ???,
val isPresent: Boolean
)
My goals are:
• Record one attendance entry per student per day.
• Generate monthly attendance reports.
• Display attendance trends using bar/line charts.
• Query attendance efficiently by day, week, month, and custom date ranges.
• Sync the same data with a backend database in the future.
I'm mainly confused about the date field. I don't need to store the exact time—only the calendar day.
What data type would you recommend for attendanceDate, and why? Are there any trade-offs between storing a Long, Date, or LocalDate in Room for this use case?