Newer
Older
ToDoApp / app / src / main / java / keijumt / todoapp / data / db / DateConverter.kt
package keijumt.todoapp.data.db

import android.arch.persistence.room.TypeConverter
import java.util.*


/**
 * Created by matsumoto_k on 2018/03/09.
 */
class DateConverter {
    @TypeConverter
    fun toDate(timestamp: Long?): Date? {
        return if (timestamp == null) null else Date(timestamp)
    }

    @TypeConverter
    fun toTimestamp(date: Date?): Long? {
        return date?.time?.toLong()
    }
}