ZonedDateTime format(DateTimeFormatter formatter)
formats this date-time using the specified formatter.
format
has the following syntax.
public String format(DateTimeFormatter formatter)
The following example shows how to use format
.
import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; //from ww w .j a v a2 s . c o m public class Main { public static void main(String[] args) { ZonedDateTime dateTime =ZonedDateTime.from(ZonedDateTime.now()); String s = dateTime.format(DateTimeFormatter.ISO_DATE_TIME); System.out.println(s); } }
The code above generates the following result.