How to format a ZonedDateTime to a String?
Many thanks for above. Here it is in scala where localDateTime.now always Zulu/UTC time.
import java.time.format.DateTimeFormatter
import java.time.LocalDateTime
import java.time.ZoneId
val ny = ZoneId.of("America/New_York")
val utc = ZoneId.of("UTC")
val dateTime = LocalDateTime.now.atZone(utc)
val nyTime = DateTimeFormatter.
ofPattern("yyyy-MMM-dd HH:mm z").
format(dateTime.withZoneSameInstant(ny))
You can use java.time.format.DateTimeFormatter. https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html
Here there is an example
ZonedDateTime date = ZonedDateTime.now();
System.out.println(DateTimeFormatter.ofPattern("dd/MM/yyyy - hh:mm").format(date));