Period of(int years, int months, int days) example

Description

Period of(int years, int months, int days) creates a Period representing a number of years, months and days.

Syntax

of has the following syntax.


public static Period of(int years,  int months,  int days)

Example

The following example shows how to use of.


import java.time.Period;
/*from www.j ava 2  s. co m*/
public class Main {
  public static void main(String[] args) {
    
    Period p = Period.of(2011,12,12);

    System.out.println(p.toString());

  }
}

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