ChronoZonedDateTime format() method in Java with Examples
The format() method of ChronoZonedDateTime interface in Java is used to format this date-time using the specified formatter passed as parameter.This date-time will be passed to the formatter to produce a string.
default String format(DateTimeFormatter formatter)
Parameters: This method accepts a single parameter formatter which represents the formatter to use. This is a mandatory parameter and should not be NULL.
Return value: This method returns a String represents the formatted date-time string.
Exception: This method throws a DateTimeException if an error occurs during printing.
Below programs illustrate the format() method:
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.