Thursday 29 March 2018

How to use multipliedBy method of Period Class | Java 8 Date and Time


Click here to watch on Youtube: 
https://www.youtube.com/watch?v=OV7gUPaUd4o&list=UUhwKlOVR041tngjerWxVccw

PeriodDemo.java

import java.time.Period;

public class PeriodDemo
{

    public static void main(String[] args)
    {

        Period period1 = Period.ofDays(12);
        System.out.println("period1 = "+period1);
       
        /*
         * Parameters:
         *
         * scalar - the scalar to multiply by, not null
         *
         * Returns:
         *
         * a Period based on this period with the amounts multiplied
         * by the scalar, not null
         */


        Period period2 = period1.multipliedBy(10);
        System.out.println("period2 = "+period2);

    }

}

Output

period1 = P12D
period2 = P120D

Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/PeriodDemo_multipliedBy.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/PeriodDemo_multipliedBy

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/755fea7aeca931764d09d2ae6d0900a44d7186bb/BasicJava_2018/PeriodDemo_multipliedBy/?at=master

See also:
  • All JavaEE Videos Playlist
  • All JavaEE Videos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • Cooking Tutorial
  • No comments:

    Post a Comment