Java ChronoLocalDate format()方法及示例
Java中ChronoLocalDate接口的format()方法使用指定的格式化器格式化这个日期。
语法:
参数 :该方法接受一个参数obj,该参数指定了要使用的格式,它不是空的。
异常 :该函数只抛出在打印过程中出现的DateTimeException错误。
返回值 :它返回格式化的日期字符串,而不是空值。
以下程序说明了Java中ChronoLocalDate的 format() 方法。
程序1 :
输出。
方案2 :为了说明这个例外情况。
输出。
参考资料 : https://docs.oracle.com/javase/9/docs/api/java/time/chrono/ChronoLocalDate.html#format-java.time.format.DateTimeFormatter-