Created
April 18, 2020 10:41
-
-
Save deepanshu42/2d244003594b3366e44819dfe178a0f4 to your computer and use it in GitHub Desktop.
TypeConverter example
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 fromTimestamp(value: Long?): Date? { | |
return value?.let { Date(it) } | |
} | |
@TypeConverter | |
fun dateToTimestamp(date: Date?): Long? { | |
return date?.time?.toLong() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment