java.time.YearMonth.parse(CharSequence text, DateTimeFormatter formatter)


java.time.YearMonth.parse(CharSequence text, DateTimeFormatter formatter)

package com.codingdict;

import java.time.YearMonth;
import java.time.format.DateTimeFormatter;

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

      DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yy-MM");
      String dateString = "17-12";
      YearMonth date = YearMonth.parse(dateString, dateTimeFormatter);
      System.out.println(date);
   }
}