Created
July 14, 2020 14:08
-
-
Save peterpazmandi/2af18e3b02c5928850ca4541396f84e8 to your computer and use it in GitHub Desktop.
Type converters to allow Room to reference complex data types.
This file contains hidden or 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
class Converters | |
{ | |
@TypeConverter fun calendarToDatestamp(calendar: Calendar): Long = calendar.timeInMillis | |
@TypeConverter fun datestampToCalendar(value: Long): Calendar = | |
Calendar.getInstance().apply { timeInMillis = value } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment