Lucca Beurmann
03/07/2022, 1:51 PMRemo
03/07/2022, 1:53 PMLucca Beurmann
03/07/2022, 1:53 PMLucca Beurmann
03/07/2022, 1:53 PMLucca Beurmann
03/07/2022, 2:10 PMLucca Beurmann
03/07/2022, 2:10 PMyyyy-mm-dd H:m:s.z
Tom Hermann
03/07/2022, 4:25 PMyyyy-MM-dd
The time part would be: HH:mm:ss.SSSSSS
The time zone offset at the end is: X
(assuming it is an iso8601 timezone offset 🤷)
So all together: yyyy-MM-dd HH:mm:ss.SSSSSSX
@Test
fun `convert sample date`() {
val time = "2019-08-16 22:16:46.919688+00"
val pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSX")
val parsed = ZonedDateTime.parse(time, pattern)
println(parsed)
}
Harshit Singh
03/10/2022, 9:16 PMconst val PATTERN_DATE_RECEIVED = "yyyy-MM-dd"
const val PATTERN_DATE_FORMATTED = "MM/dd/yyyy"
private fun getFormattedDate(dateTime: String?): String {
val input = SimpleDateFormat(PATTERN_DATE_RECEIVED)
val output = SimpleDateFormat(PATTERN_DATE_FORMATTED)
try {
return output.format(input.parse(dateTime?.substring(0, 10) ?: "") ?: "")
} catch (e: ParseException) {
e.printStackTrace()
}
return ""
}