offsetdatetime

Kotlin DateTimeParseException

此生再无相见时 提交于 2021-02-11 12:32:24
问题 Getting date from https://api.spacexdata.com/v3/launches This date have format: 2006-03-25T10:30:00+12:00. I want convert it to "dd, mm, yyyy", but always getting error: "java.time.format.DateTimeParseException: Text '2006-03-25T10:30:00+12:00' could not be parsed, unparsed text found at index 10" my code: val formatter = DateTimeFormatter.ofPattern("dd, mm, yyyy", Locale.US) val myDate = LocalDate.parse(launchDate, formatter) var launchDateConverted: String= myDate.toString() i getting data

DateTimeFormatter issue

折月煮酒 提交于 2021-02-10 15:15:19
问题 See the following test code (java 11): public static final String DATE_FORMAT_TIMESTAMP = "YYYY-MM-dd'T'HH:mm:ss'Z'"; ... var timestamp = OffsetDateTime.now(); System.out.println(timestamp); var formatter = DateTimeFormatter.ofPattern(DATE_FORMAT_TIMESTAMP); var zt = timestamp.format(formatter); System.out.println(zt); ... The output: enter code here 2020-12-27T23:34:34.886272600+02:00 2021-12-27T23:34:34Z Note formatted time year is 2021 . And it happens only from 27/12, probably till 31/12.