Java Period add subtract period

Description

Java Period add subtract period

import java.time.Period;

public class Main {
  public static void main(String[] args) {
    Period p1 = Period.of(12, 3, 5);
    Period p2 = Period.of(1, 15, 28);

    System.out.println("p1: " + p1);
    System.out.println("p2: " + p2);
    System.out.println("p1.plus(p2): " + p1.plus(p2));
    System.out.println("p1.plus(p2).normalized(): " + p1.plus(p2).normalized());
    System.out.println("p1.minus(p2): " + p1.minus(p2));

  }/*from ww  w  .  j  a  v  a 2 s . co  m*/
}



PreviousNext

Related