UTC Epoch miliseconds to LocalDateTime
val milliseconds = sharedPref.getLong(key, 0)val localDateTime = if (milliseconds == 0L) null else LocalDateTime.ofInstant(Instant.ofEpochMilli(milliseconds), ZoneOffset.UTC)
LocalDateTime to UTC Epoch miliseconds
val milliseconds = localDateTime?.atZone(ZoneOffset.UTC)?.toInstant()?.toEpochMilli() ?: 0sharedPref.edit { putLong(key, milliseconds)}
NOTE: Android KTX is used for sharedPref.edit
.