JAVA 8 / NOTES</>↗Java 817 Jan 2024
The java.time.temporal.TemporalAdjuster interface and the java.time.temporal.TemporalAdjusters class are both part of the Java Date-Time API, and they work together for adjusting temporal objects. TemporalAdjuster interface: This is a functional interface, which means it has only one abstract method, adjustInto(). This method is meant to adjust a temporal object, such as LocalDate, LocalDateTime, YearMonth, etc. The […]
JAVA 8 / NOTES</>↗Java 817 Jan 2024
java.time.Duration is another useful class in Java for dealing with time. It measures time in seconds and nanoseconds and is most suitable for smaller amounts of time, like “20 seconds” or “3 hours”, and not for larger units like “3 days” or “4 months”. Here’s a guide on how to use it: 1. Creating a […]
JAVA 8 / NOTES</>↗Java 817 Jan 2024
java.time.Period is a class that represents a quantity or amount of time in terms of years, months, and days. Here’s a brief guide on how to use it: 1. Creating a Period instance The Period class provides several static methods named of() and between() to create an instance. To create Period of 1 year, 2 […]
JAVA 8 / NOTES</>↗Java 817 Jan 2024
ChronoUnit is an enumeration that provides static constants representing the units of time in the date-time API in Java. These constants include DAYS, HOURS, SECONDS, etc., that are often used to measure a quantity of time with respect to the specifics of a calendar system. Here’s an example of how you can use the ChronoUnit […]
JAVA 8 / NOTES</>↗Java 817 Jan 2024
In the Java Date-Time API, the plus and minus methods can be used to calculate and modify dates, times, date/times, and durations. Each temporal class (LocalDate, LocalTime, LocalDateTime, and Duration) includes these methods. Here’s a basic example using the LocalDate class: package org.kodejava.datetime; import java.time.LocalDate; public class PlusMinusExample { public static void main(String[] args) { […]
JAVA 8 / NOTES</>↗Java 815 Jan 2024
The atDate() method is a part of LocalTime class in the Java Date-Time API. This method combines this time with a date to create an instance of LocalDateTime. Here’s an example: package org.kodejava.datetime; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; public class AtDateExample { public static void main(String[] args) { // Create a LocalTime instance LocalTime […]