Created
March 4, 2021 08:35
-
-
Save robertlevonyan/2978f04e6564cdb9f3fb3db634636675 to your computer and use it in GitHub Desktop.
This file contains 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 DateAdapter : ColumnAdapter<Date, String> { | |
companion object { | |
private val format = SimpleDateFormat("yyyy-MM-dd", Locale.US) | |
} | |
override fun decode(databaseValue: String): Date = format.parse(databaseValue) ?: Date() | |
override fun encode(value: Date): String = format.format(value) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment