Skip to content

Instantly share code, notes, and snippets.

@robertlevonyan
Created March 4, 2021 08:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertlevonyan/2978f04e6564cdb9f3fb3db634636675 to your computer and use it in GitHub Desktop.
Save robertlevonyan/2978f04e6564cdb9f3fb3db634636675 to your computer and use it in GitHub Desktop.
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