- 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
235 Views
The day of the month for a particular LocalDateTime can be obtained using the getDayOfMonth() method in the LocalDateTime class in Java. This method requires no parameters and it returns the day of the month which can be in the range of 1 to 31.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { LocalDateTime ldt = LocalDateTime.parse("2019-02-18T11:30:15"); System.out.println("The LocalDateTime is: " + ldt); System.out.println("The day of ... Read More
114 Views
The day of the week for a particular LocalDateTime can be obtained using the getDayOfWeek() method in the LocalDateTime class in Java. This method requires no parameters and it returns the day of the week.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { LocalDateTime ldt = LocalDateTime.parse("2019-02-18T11:30:15"); System.out.println("The LocalDateTime is: " + ldt); System.out.println("The day of the week is: " + ldt.getDayOfWeek()); } ... Read More
30 Views
The length of the year in a particular LocalDate is obtained using the method lengthOfYear() in the LocalDate class in Java. This method requires no parameters and it returns the length of the year in a particular LocalDate i.e. 365 or 366 for a leap year.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("2019-02-15"); System.out.println("The LocalDate is: " + ld); System.out.println("The length ... Read More
197 Views
The hash code value of the LocalDate can be obtained using the hashCode() method in the LocalDate class in Java. This method requires no parameters and it returns the hash code value of the LocalDate.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("2019-02-15"); System.out.println("The LocalDate is: " + ld); System.out.println("The hash code is: " + ld.hashCode()); } }OutputThe LocalDate ... Read More
43 Views
An immutable copy of a LocalDate with the day of year altered as required is done using the method withDayOfYear() in the LocalDate class in Java. This method requires a single parameter i.e. the day of year that is to be set in the LocalDate and it returns the LocalDate with the day of year altered as required.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-15"); System.out.println("The LocalDate ... Read More
116 Views
An immutable copy of a LocalDate with the day of month altered as required is done using the method withDayOfMonth() in the LocalDate class in Java. This method requires a single parameter i.e. the day of month that is to be set in the LocalDate and it returns the LocalDate with the day of month altered as required.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-15"); System.out.println("The LocalDate is: " + ld1); ... Read More
112 Views
An immutable copy of a LocalDate with the month altered as required is done using the method withMonth() in the LocalDate class in Java. This method requires a single parameter i.e. the month that is to be set in the LocalDate and it returns the LocalDate with the month altered as required.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-15"); System.out.println("The LocalDate is: " + ld1); ... Read More
126 Views
An immutable copy of a LocalDate with the year altered as required is done using the method withYear() in the LocalDate class in Java. This method requires a single parameter i.e. the year that is to be set in the LocalDate and it returns the LocalDate with the year altered as required.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-15"); System.out.println("The LocalDate is: " + ld1); ... Read More
419 Views
The range of values for a ChronoField can be obtained using the range() method in the LocalDate class in Java. This method requires a single parameter i.e. the ChronoField for which the range of values is required and it returns the range of values.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; import java.time.temporal.ChronoField; import java.time.temporal.ValueRange; public class Main { public static void main(String[] args) { LocalDate ld = LocalDate.parse("2019-02-15"); System.out.println("The LocalDate is: " + ld); ... Read More
236 Views
The string value of the LocalDate object can be obtained using the method toString() in the LocalDate class in Java. This method requires no parameters and it returns the string value of the LocalDate object.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: " + ld.toString()); } }OutputThe LocalDate is: 2019-02-15Now let us understand the above program.The string value of the LocalDate ... Read More