Java Date Time - Period ofDays(int days) example








Period ofDays(int days) creates a Period representing a number of days.

Syntax

ofDays has the following syntax.

public static Period ofDays(int days)

Example

The following example shows how to use ofDays.

import java.time.Period;
/*ww  w .j a va  2 s  . co m*/
public class Main {
  public static void main(String[] args) {
    
    Period p = Period.ofDays(12);

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

  }
}

The code above generates the following result.