![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 9326 Articles for Object Oriented Programming
![Krantik Chavan](https://www.tutorialspoint.com/assets/profiles/13545/profile/60_126883-1512724834.jpg)
30 Views
The total number of months for a particular Period can be obtained using the toTotalMonths() method in the Period class in Java. This method requires no parameters and it returns the total number of months in the Period in the form of a long value.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; public class Demo { public static void main(String[] args) { String period = "P2Y1M15D"; Period p = Period.parse(period); System.out.println("The Period is: " + p); System.out.println("The total number of months are: " + ... Read More
![Daniol Thomas](https://www.tutorialspoint.com/assets/profiles/13551/profile/60_130035-1512726078.jpg)
113 Views
It can be checked if the days, months and years in the Period are zero or not using the isZero() method in the Period class in Java. This method requires no parameters. Also, it returns true if the days, months and years in the Period are zero and false otherwise.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; public class Demo { public static void main(String[] args) { String period = "P0Y0M0D"; Period p = Period.parse(period); System.out.println("The Period is: " + p); System.out.println("The days, months ... Read More
![Daniol Thomas](https://www.tutorialspoint.com/assets/profiles/13551/profile/60_130035-1512726078.jpg)
172 Views
The number of years for a particular Period can be obtained using the getYears() method in the Period class in Java. This method requires no parameters and it returns the number of years in the Period.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; public class Demo { public static void main(String[] args) { String period = "P5Y7M15D"; Period p = Period.parse(period); System.out.println("The Period is: " + p); System.out.println("The number of years are: " + p.getYears()); } }OutputThe Period is: P5Y7M15D The number of ... Read More
![Daniol Thomas](https://www.tutorialspoint.com/assets/profiles/13551/profile/60_130035-1512726078.jpg)
90 Views
The number of months for a particular Period can be obtained using the getMonths() method in the Period class in Java. This method requires no parameters and it returns the number of months in the Period.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; public class Demo { public static void main(String[] args) { String period = "P5Y7M15D"; Period p = Period.parse(period); System.out.println("The Period is: " + p); System.out.println("The number of months are: " + p.getMonths()); } }OutputThe Period is: P5Y7M15D The number of ... Read More
![Daniol Thomas](https://www.tutorialspoint.com/assets/profiles/13551/profile/60_130035-1512726078.jpg)
280 Views
The number of days for a particular Period can be obtained using the getDays() method in the Period class in Java. This method requires no parameters and it returns the number of days in the Period.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; public class Demo { public static void main(String[] args) { String period = "P5Y7M15D"; Period p = Period.parse(period); System.out.println("The Period is: " + p); System.out.println("The number of days are: " + p.getDays()); } } OutputThe Period is: P5Y7M15D The ... Read More
![Daniol Thomas](https://www.tutorialspoint.com/assets/profiles/13551/profile/60_130035-1512726078.jpg)
98 Views
The hash code value of the Period can be obtained using the hashCode() method in the Period class in Java. This method requires no parameters and it returns the hash code value of the Period.A program that demonstrates this is given as follows:Example Live Demoimport java.time.Period; public class Demo { public static void main(String[] args) { String period = "P5Y7M15D"; Period p = Period.parse(period); System.out.println("The Period is: " + p); System.out.println("The hash code is: " + p.hashCode()); } }OutputThe Period is: P5Y7M15D The hash code is: 984837Now ... Read More
![Nancy Den](https://www.tutorialspoint.com/assets/profiles/13557/profile/60_88439-1512714529.jpg)
96 Views
An immutable copy of the Period object where some years are subtracted from it can be obtained using the minusYears() method in the Period class in Java. This method requires a single parameter i.e. the number of years to be subtracted and it returns the Period object with the subtracted years.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; public class Demo { public static void main(String[] args) { String period = "P5Y7M15D"; Period p1 = Period.parse(period); System.out.println("The Period is: " + p1); Period p2 ... Read More
![Nancy Den](https://www.tutorialspoint.com/assets/profiles/13557/profile/60_88439-1512714529.jpg)
92 Views
An immutable copy of the Period object where some months are subtracted from it can be obtained using the minusMonths() method in the Period class in Java. This method requires a single parameter i.e. the number of months to be subtracted and it returns the Period object with the subtracted months.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; public class Demo { public static void main(String[] args) { String period = "P5Y7M15D"; Period p1 = Period.parse(period); System.out.println("The Period is: " + p1); Period p2 ... Read More
![Nancy Den](https://www.tutorialspoint.com/assets/profiles/13557/profile/60_88439-1512714529.jpg)
104 Views
An immutable copy of the Period object where some days are subtracted from it can be obtained using the minusDays() method in the Period class in Java. This method requires a single parameter i.e. the number of days to be subtracted and it returns the Period object with the subtracted days.A program that demonstrates this is given as follows:Example Live Demoimport java.time.Period; public class Demo { public static void main(String[] args) { String period = "P5Y7M15D"; Period p1 = Period.parse(period); System.out.println("The Period is: " + p1); Period p2 ... Read More
![Nancy Den](https://www.tutorialspoint.com/assets/profiles/13557/profile/60_88439-1512714529.jpg)
93 Views
An immutable copy of the Period object where some years are added to it can be obtained using the plusYears() method in the Period class in Java. This method requires a single parameter i.e. the number of years to be added and it returns the Period object with the added years.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; public class Demo { public static void main(String[] args) { String period = "P5Y7M15D"; Period p1 = Period.parse(period); System.out.println("The Period is: " + p1); Period p2 ... Read More