Android Read Exif Date as LocalDateTime

June 18, 2018
val exif = ExifInterface(filePath)

val date = exif.getAttribute(ExifInterface.TAG_DATETIME).let { value ->
   if (!value.isNullOrEmpty()) {
        // 2017:08:05 21:21:24
        val formatter = DateTimeFormatter.ofPattern("yyyy:MM:dd HH:mm:ss")
        LocalDateTime.parse(value, formatter)
    }
    else {
        null
    }
}

NOTE: Sadly there is no way to get timezone from EXIF data.

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.