MonthDay parse(CharSequence text, DateTimeFormatter formatter) example

Description

MonthDay parse(CharSequence text, DateTimeFormatter formatter) creates an instance of MonthDay from a text string using a specific formatter.

Syntax

parse has the following syntax.


public static MonthDay parse(CharSequence text,   DateTimeFormatter formatter)

Example

The following example shows how to use parse.


import java.time.MonthDay;
import java.time.format.DateTimeFormatter;
//from  ww w  .  ja va  2s  .  co m
public class Main {
  public static void main(String[] args) {
    MonthDay m = MonthDay.parse("10 10",DateTimeFormatter.ofPattern("M dd"));

    System.out.println(m);

  }
}

The code above generates the following result.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset