Year format(DateTimeFormatter formatter)
formats this year 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.Year; import java.time.format.DateTimeFormatter; /* w w w. j av a2 s . c o m*/ public class Main { public static void main(String[] args) { Year y = Year.of(2014); String l = y.format(DateTimeFormatter.ofPattern("yyyy")); System.out.println(l); } }
The code above generates the following result.