Java Convert ZonedDateTime to String Example

ZonedDateTime class provides below APIs to convert or format ZonedDateTime to String in Java.
  • String format(DateTimeFormatter formatter) - Formats this date-time using the specified formatter.

Java Convert ZonedDateTime to String Example

import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

 * Program to demonstrate ZonedDateTime Class APIs.
 * @author
public class ZonedDateTimeExample {
    public static void main(String[] args) {

    private static void convertorformatZonedDateTimetoString() {
         // ISO pattern
        ZonedDateTime dateTime =;

        // 'yyyy-MMM-dd HH:mm:ss z' pattern
        System.out.println(dateTime.format(DateTimeFormatter.ofPattern("yyyy-MMM-dd HH:mm:ss z")));

        // 'yyyy-MM-dd KK:mm:ss a' pattern
        System.out.println(dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd KK:mm:ss a")));

       // 'cccc, MMMM dd, yyyy KK:mm a' pattern
        System.out.println(dateTime.format(DateTimeFormatter.ofPattern("cccc, MMMM dd, yyyy KK:mm a")));
2018-Aug-11 11:31:27 IST
2018-08-11 11:31:27 AM
Saturday, August 11, 2018 11:31 AM