Skip to content

Instantly share code, notes, and snippets.

@AkshayChordiya
Created December 9, 2017 08:55
Show Gist options
  • Select an option

  • Save AkshayChordiya/7ea8e277049c09ce71c702282946720e to your computer and use it in GitHub Desktop.

Select an option

Save AkshayChordiya/7ea8e277049c09ce71c702282946720e to your computer and use it in GitHub Desktop.

Revisions

  1. AkshayChordiya created this gist Dec 9, 2017.
    11 changes: 11 additions & 0 deletions DateConverters.kt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    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
    }
    }