Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Date Converter for Room
class DateConverters {
@TypeConverter
fun fromTimestamp(value: Long?): Date? {
return if (value == null) null else Date(value)
}
@TypeConverter
fun dateToTimestamp(date: Date?): Long? {
return date?.time
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment