Java Date Time - Period ofWeeks(int weeks) example








Period ofWeeks(int weeks) creates a Period representing a number of weeks.

Syntax

ofWeeks has the following syntax.

public static Period ofWeeks(int weeks)

Example

The following example shows how to use ofWeeks.

import java.time.Period;
//from w  w w.j  ava2  s  .  c  o m
public class Main {
  public static void main(String[] args) {
    
    Period p = Period.ofWeeks(12);

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

  }
}

The code above generates the following result.