Java Convert Weeks to Period

Tags: Java Period Java 8

In this Java core tutorial we learn how to convert a number of weeks to java.time.Period object in Java programming language.

How to convert weeks to Period in Java

In Java, we can use the Period.ofWeeks(int weeks) static method to instantiate a new Period object from number of weeks as the example Java code below.

import java.time.Period;

public class ConvertWeeksToPeriodExample1 {
    public static void main(String... args) {
        int numberOfWeeks = 57;

        Period period = Period.ofWeeks(numberOfWeeks);

        System.out.println("Number of weeks: " + numberOfWeeks);
        System.out.println("Period: " + period);
The output as below.
Number of weeks: 57
Period: P399D

Happy Coding 😊

Java Convert Years to Period

Java Convert Months to Period

Java Convert Days to Period

Java Convert Days Months Years to Period

Java Convert String to Period