- Trending Categories
- 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 4336 Articles for Java 8
2K+ Views
An immutable copy of a LocalDate where the required duration is subtracted from it can be obtained using the minus() method in the LocalDate class in Java. This method requires two parameters i.e. the duration to be subtracted and the TemporalUnit of the duration. Also, it returns the LocalDate object with the required duration subtracted from it.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; import java.time.temporal.*; public class Demo { public static void main(String[] args) { LocalDate ld = LocalDate.parse("2019-02-15"); System.out.println("The ... Read More
456 Views
An immutable copy of a LocalDate where the required duration is added to it can be obtained using the plus() method in the LocalDate class in Java. This method requires two parameters i.e. the duration to be added and the TemporalUnit of the duration. Also, it returns the LocalDate object with the required duration added to it.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; import java.time.temporal.*; public class Demo { public static void main(String[] args) { LocalDate ld = LocalDate.parse("2019-02-15"); System.out.println("The ... Read More
165 Views
The LocalDate instance can be obtained from a string value using the parse() method in the LocalDate class in Java. This method requires a single parameter i.e. the string which is to be parsed. This string cannot be null. Also, it returns the LocalDate instance obtained from the string value that was passed as a parameter.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { LocalDate ld = LocalDate.parse("2019-02-15"); System.out.println("The LocalDate is: " ... Read More
113 Views
The LocalDate object can be queried as required using the query method in the LocalDate class in Java. This method requires a single parameter i.e. the query to be invoked and it returns the result of the query.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; import java.time.temporal.*; public class Demo { public static void main(String[] args) { LocalDate ld = LocalDate.parse("2019-02-14"); System.out.println("The LocalDate is: " + ld); String precision = ld.query(TemporalQueries.precision()).toString(); ... Read More
194 Views
The current date can be obtained from the system clock in the default time zone using the now() method in the LocalDate class in Java. This method requires no parameters and it returns the current date from the system clock in the default time zoneA program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { LocalDate ld = LocalDate.now(); System.out.println("The LocalDate is: " + ld); } }OutputThe LocalDate is: 2019-02-15Now let ... Read More
110 Views
The Period can be obtained with the given number of weeks using the ofWeeks() method in the Period class in Java. This method requires a single parameter i.e. the number of weeks and it returns the Period object with the given number of weeks.A program that demonstrates this is given as follows −Example Live Demoimport java.time.Period; public class Demo { public static void main(String[] args) { int weeks = 7; Period p = Period.ofWeeks(weeks); System.out.println("The Period is: " + p); ... Read More
141 Views
The Period can be obtained with the given number of years using the ofYears() method in the Period class in Java. This method requires a single parameter i.e. the number of years and it returns the Period object with the given number of years.A program that demonstrates this is given as follows −Example Live Demoimport java.time.Period; public class Demo { public static void main(String[] args) { int years = 3; Period p = Period.ofYears(years); System.out.println("The Period is: " + p); ... Read More
160 Views
The Period can be obtained with the given number of months using the ofMonths() method in the Period class in Java. This method requires a single parameter i.e. the number of months and it returns the Period object with the given number of months.A program that demonstrates this is given as follows −Example Live Demoimport java.time.Period; public class Demo { public static void main(String[] args) { int months = 11; Period p = Period.ofMonths(months); System.out.println("The Period is: " + p); ... Read More
254 Views
The Period can be obtained with the given number of days using the ofDays() method in the Period class in Java. This method requires a single parameter i.e. the number of days and it returns the Period object with the given number of 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) { int days = 5; Period p = Period.ofDays(days); System.out.println("The Period is: " + p); ... Read More
614 Views
An immutable copy of the LocalDate where the months are subtracted from it can be obtained using the minusMonths() method in the LocalDate class in Java. This method requires a single parameter i.e. the number of months to be subtracted and it returns the instant with the subtracted months.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { LocalDate ld1 = LocalDate.parse("2019-02-14"); System.out.println("The LocalDate is: " + ld1); ... Read More