What would be the best way to go about this. I am using 2 different APIs and one returns a date as a String and the other returns date as an Int timestamp in the format of e.g. 162000360
I was using the ThreeTen backport for Date/Time classes. I have successfully created a type convertor for the date I get back as a String - provided below
@TypeConverter
@JvmStatic
fun stringToDate(str: String?) = str?.let {
LocalDate.parse(it, DateTimeFormatter.ISO_LOCAL_DATE)
}
@TypeConverter
@JvmStatic
fun dateToString(dateTime: LocalDate?) = dateTime?.format(DateTimeFormatter.ISO_LOCAL_DATE)
I'm struggling to replicate the same for the Int timestamp as the DateTimeFormatter requires a String passed into it and won't allow an Int. Any help is much appreciated
I was using the ThreeTen backport for Date/Time classes. I have successfully created a type convertor for the date I get back as a String - provided below
@TypeConverter
@JvmStatic
fun stringToDate(str: String?) = str?.let {
LocalDate.parse(it, DateTimeFormatter.ISO_LOCAL_DATE)
}
@TypeConverter
@JvmStatic
fun dateToString(dateTime: LocalDate?) = dateTime?.format(DateTimeFormatter.ISO_LOCAL_DATE)
I'm struggling to replicate the same for the Int timestamp as the DateTimeFormatter requires a String passed into it and won't allow an Int. Any help is much appreciated