Example usage for java.time Period ofMonths

List of usage examples for java.time Period ofMonths

Introduction

In this page you can find the example usage for java.time Period ofMonths.

Prototype

public static Period ofMonths(int months) 

Source Link

Document

Obtains a Period representing a number of months.

Usage

From source file:Main.java

public static void main(String[] args) {
    Period p = Period.ofMonths(1);

    Period l = p.withMonths(10);
    System.out.println(l);

}

From source file:Main.java

public static void main(String[] args) {
    Period p = Period.ofMonths(1);

    Period l = p.plusMonths(12);
    System.out.println(l);

}

From source file:Main.java

public static void main(String[] args) {

    Period p = Period.ofMonths(12);

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

}

From source file:Main.java

public static void main(String[] args) {

    Period p = Period.from(Period.ofMonths(12));

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

}

From source file:Main.java

public static void main(String[] args) {

    Period twoMonthsAndFiveDays = Period.ofMonths(2).plusDays(5);

    System.out.println(twoMonthsAndFiveDays);
}

From source file:Main.java

public static void main(String[] args) {
    Period p = Period.ofMonths(1);

    System.out.println(p.get(ChronoUnit.DAYS));

}

From source file:Main.java

public static void main(String[] args) {
    Period twoMonthsAndFiveDays = Period.ofMonths(2).plusDays(5);
    LocalDate sixthOfJanuary = LocalDate.of(2014, 1, 6);

    LocalDate eleventhOfMarch = sixthOfJanuary.plus(twoMonthsAndFiveDays);

    System.out.println(eleventhOfMarch);
}

From source file:Main.java

public static void main(String[] args) {
    Period p = Period.ofDays(30);
    System.out.println(p);//from w  ww  . ja va 2  s .c o m

    Period p1 = Period.ofMonths(12);
    System.out.println(p1);

    Period p2 = Period.ofWeeks(11);
    System.out.println(p2);

    Period p3 = Period.ofYears(50); // years, months, days
    System.out.println(p3);
}