Java Date Time - MonthDay parse(CharSequence text) example








MonthDay parse(CharSequence text) creates an instance of MonthDay from a text string such as --12-03.

The string must represent a valid month-day. The format is --MM-dd.

Syntax

parse has the following syntax.

public static MonthDay parse(CharSequence text)

Example

The following example shows how to use parse.

import java.time.MonthDay;
/*w  w  w . ja v a  2  s .co  m*/
public class Main {
  public static void main(String[] args) {
    MonthDay m = MonthDay.parse("--12-03");

    System.out.println(m);

  }
}

The code above generates the following result.