Created
March 18, 2022 11:05
-
-
Save carolinemusyoka/bb5e0c7e1b838022a859b6189d9331e5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | |
val parsedDate = LocalDateTime.parse(item.created_at, DateTimeFormatter.ISO_DATE_TIME) | |
val formattedDate = parsedDate.format(DateTimeFormatter.ofPattern("dd.MM.yyyy | HH:mm")) | |
textCreatedTime.text = formattedDate | |
} else { | |
val parser = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss") | |
val formatter = SimpleDateFormat("dd.MM.yyyy | HH:mm") | |
val formattedDate = formatter.format(parser.parse(item.created_at)!!) | |
textCreatedTime.text = formattedDate | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment