YearMonth parse(CharSequence text) example

Description

YearMonth parse(CharSequence text) create an instance of YearMonth from a text string such as 2014-12.

Syntax

parse has the following syntax.


public static YearMonth parse(CharSequence text)

Example

The following example shows how to use parse.


import java.time.YearMonth;
//w ww. j a  v  a 2  s. c  o m
public class Main {
  public static void main(String[] args) {
    YearMonth y = YearMonth.parse("2013-09");
    
    System.out.println(y);

  }
}

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