java.time.Year.format() 方法示例


java.time.Year.format() 方法示例

package com.codingdict;

import java.time.Year;
import java.time.format.DateTimeFormatter;

public class YearDemo {
   public static void main(String[] args) {

      Year date = Year.of(2017);
      System.out.println(date);  
      DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yy");
      System.out.println(formatter.format(date));  
   }
}