Example usage for java.time Period ofYears

List of usage examples for java.time Period ofYears

Introduction

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

Prototype

public static Period ofYears(int years) 

Source Link

Document

Obtains a Period representing a number of years.

Usage

From source file:Main.java

public static void main(String[] args) {

    Period p = Period.ofYears(12);

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

}

From source file:Main.java

public static void main(String[] args) {
    int years = 3;
    int months = 6;
    Period time = Period.ofYears(years).withMonths(months);

    System.out.println(time.getYears());
    System.out.println(time.getMonths());
}

From source file:Main.java

public static void main(String[] args) {
    Year y = Year.of(2014);
    Year l = y.plus(Period.ofYears(12));
    System.out.println(l);

}

From source file:Main.java

public static void main(String[] args) {
    Year y = Year.of(2014);
    Year l = y.minus(Period.ofYears(12));
    System.out.println(l);

}

From source file:Main.java

public static void main(String[] argv) {
    int yearsAtOctanner = 4;
    int monthsAtOctanner = 6;
    Period periodAtOct = Period.ofYears(yearsAtOctanner).withMonths(monthsAtOctanner);
    System.out.println("periodAtOct = " + periodAtOct);
}

From source file:Main.java

public static void main(String[] args) {
    YearMonth y = YearMonth.now();
    YearMonth s = y.plus(Period.ofYears(3));
    System.out.println(s);/*from www. j  a va 2  s. c om*/

}

From source file:Main.java

public static void main(String[] args) {
    YearMonth y = YearMonth.now();
    YearMonth s = y.minus(Period.ofYears(3));
    System.out.println(s);//www.j  a  v a2s  . c  o  m

}

From source file:Main.java

public static void main(String[] args) {
    ZonedDateTime dateTime = ZonedDateTime.now();
    ZonedDateTime n = dateTime.plus(Period.ofYears(12));
    System.out.println(n);/*from   w ww.  j a  va 2s.c  om*/
}

From source file:Main.java

public static void main(String[] args) {
    Period p = Period.ofDays(30);
    System.out.println(p);//  www  . ja  v  a 2s.  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);
}