Java ZonedDateTime format to String like "09 o'clock AM, Pacific Daylight Time"
import java.time.DateTimeException; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; public class Main { public static void main(String[] args) { try {//from w w w .j av a 2 s .c om DateTimeFormatter dateFormatter3 = DateTimeFormatter.ofPattern("hh 'o''clock' a, zzzz"); ZonedDateTime zdt = ZonedDateTime.now(); String output3 = zdt.format(dateFormatter3); System.out.println(output3); } catch (DateTimeException ex) { System.out.println("Cannot be formatted: " + ex); } } }