Say you have a string with a date and a time, e.g "24.07.2019 12:49"
, but no time zone.
And you want to format that string according to the ISO-8601 standard, with offset, e.g "2019-07-24T12:49:00+02:00"
.
In java:
LocalDate date = LocalDate.parse("27.07.2019", DateTimeFormatter.ofPattern("dd.MM.yyyy"));
LocalTime time = LocalTime.parse("12:49");
LocalDateTime.of(date, time)
.atZone(ZoneId.of("Europe/Oslo"))
.toOffsetDateTime()
.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); //"2019-07-24T12:49:00+02:00"