Created
December 9, 2017 08:55
-
-
Save AkshayChordiya/7ea8e277049c09ce71c702282946720e to your computer and use it in GitHub Desktop.
Date Converter for Room
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 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