- 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
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
72 Views
The LocalDate can be formatted with the specified formatter using the format() method in the LocalDate class in Java. This method requires a single parameter i.e. the LocalDate object to be formatted and it returns the formatted LocalDate with the specified formatter.A program that demonstrates this is given as follows −Example Live Demoimport java.util.*; import java.time.*; import java.time.format.DateTimeFormatter; public class Main { public static void main(String[] args) { LocalDate ld = LocalDate.parse("2019-02-14"); System.out.println("The LocalDate is: " + ld); DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd/MM/YYYY"); System.out.println("The formatted LocalDate is: " + ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
83 Views
An instance of a LocalDate object can be obtained from a Temporal object using the from() method in the LocalDate class in Java. This method requires a single parameter i.e. the Temporal object and it returns the LocalDate object that is obtained from the Temporal object.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main { public static void main(String[] args) { LocalDate ld = LocalDate.from(ZonedDateTime.now()); System.out.println("The LocalDate is: " + ld); } }OutputThe LocalDate is: 2019-02-16Now let us understand the above program.The instance of the LocalDate ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
3K+ Views
Two LocalDate objects can be compared using the compareTo() method in the LocalDate class in Java. This method requires a single parameter i.e. the LocalDate object to be compared.If the first LocalDate object is greater than the second LocalDate object it returns a positive number, if the first LocalDate object is lesser than the second LocalDate object it returns a negative number and if both the LocalDate objects are equal it returns zero.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main { public static void main(String[] args) { LocalDate ld1 ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
70 Views
It can be checked if the LocalDate is in a leap year or not using the isLeapYear() method in the LocalDate class in Java. This method requires no parameters. It returns true if the LocalDate is in a leap year and false otherwise.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main { public static void main(String[] args) { LocalDate ld = LocalDate.parse("2012-10-12"); System.out.println("The LocalDate is: " + ld); boolean flag = ld.isLeapYear(); if(flag) System.out.println("This is a leap ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
990 Views
It can be checked if two LocalDate objects are equal or not using the isEqual() method in the LocalDate class in Java. This method requires a single parameter i.e. the LocalDate object that is to be compared. It returns true if the two LocalDate objects are equal and false otherwise.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main { public static void main(String[] args) { LocalDate ld1 = LocalDate.parse("2019-02-12"); LocalDate ld2 = LocalDate.parse("2019-02-12"); System.out.println("The LocalDate ld1 is: " + ld1); System.out.println("The ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
633 Views
It can be checked if a particular LocalDate is before the other LocalDate in a timeline using the isBefore() method in the LocalDate class in Java. This method requires a single parameter i.e. the LocalDate object that is to be compared. It returns true if the LocalDate object is before the other LocalDate object and false otherwise.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main { public static void main(String[] args) { LocalDate ld1 = LocalDate.parse("2019-02-12"); LocalDate ld2 = LocalDate.parse("2019-02-14"); System.out.println("The LocalDate ld1 is: ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
1K+ Views
It can be checked if a particular LocalDate is after the other LocalDate in a timeline using the isAfter() method in the LocalDate class in Java. This method requires a single parameter i.e. the LocalDate object that is to be compared. It returns true if the LocalDate object is after the other LocalDate object and false otherwise.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main { public static void main(String[] args) { LocalDate ld1 = LocalDate.parse("2019-02-20"); LocalDate ld2 = LocalDate.parse("2019-02-14"); System.out.println("The LocalDate ld1 is: ... Read More
![Nancy Den](https://www.tutorialspoint.com/assets/profiles/13557/profile/60_88439-1512714529.jpg)
147 Views
It can be checked if a particular Instant object is after the other Instant object in a timeline using the isAfter() method in the Instant class in Java. This method requires a single parameter i.e. the Instant object that is to be compared. It returns true if the Instant object is after the other Instant object and false otherwise.A program that demonstrates this is given as followsExample Live Demoimport java.time.*; import java.time.temporal.ChronoUnit; public class Demo { public static void main(String[] args) { Instant i1 = Instant.parse("2019-01-13T16:10:35.00Z"); Instant i2 = Instant.parse("2019-01-13T11:19:28.00Z"); boolean ... Read More
![Nancy Den](https://www.tutorialspoint.com/assets/profiles/13557/profile/60_88439-1512714529.jpg)
167 Views
It can be checked if a particular Instant object is before the other Instant object in a timeline using the isBefore() method in the Instant class in Java. This method requires a single parameter i.e. the Instant object that is to be compared. It returns true if the Instant object is before the other Instant object and false otherwise.A program that demonstrates this is given as followsExample Live Demoimport java.time.*; import java.time.temporal.ChronoUnit; public class Demo { public static void main(String[] args) { Instant i1 = Instant.parse("2019-01-13T11:45:13.00Z"); Instant i2 = Instant.parse("2019-01-13T15:30:12.00Z"); boolean ... Read More
![Nancy Den](https://www.tutorialspoint.com/assets/profiles/13557/profile/60_88439-1512714529.jpg)
164 Views
An immutable copy of a Period with the number of days as required is done using the method withDays() in the Period class in Java. This method requires a single parameter i.e. the number of days in the Period and it returns the Period with the number of days as required.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