JAVA 8 / CATATAN</>↗Java 818 Jan 2024
java.time.ZoneId is a class in Java’s Date-Time API used to represent a time zone identifier. This identifier is used to get a ZoneRules, which then can be used to convert between an Instant and a LocalDateTime. Here is how you can use the ZoneId class in a simple way: package org.kodejava.datetime; import java.time.ZoneId; import java.time.ZonedDateTime; […]
JAVA 8 / CATATAN</>↗Java 818 Jan 2024
The java.time.Instant class in the Java Date-Time API is an immutable representation of a point in time. It stores a long count of seconds from the epoch of the first moment of 1970 UTC, plus a number of nanoseconds for the further precision within that second. The java.time.LocalDate class represents a date without a time […]
JAVA 8 / CATATAN</>↗Java 817 Jan 2024
TemporalAdjusters.next(DayOfWeek) and TemporalAdjusters.nextOrSame(DayOfWeek) are part of java.time.temporal.TemporalAdjusters class in Java. They adjust the date to the next, or the first occurrence of the specified DayOfWeek, or stay at the same date if it’s the desired DayOfWeek. Here is how to use these methods: package org.kodejava.datetime; import java.time.DayOfWeek; import java.time.LocalDate; import java.time.temporal.TemporalAdjusters; public class NextOrSameExample...
JAVA 8 / CATATAN</>↗Java 817 Jan 2024
TemporalAdjusters.firstInMonth(DayOfWeek) and TemporalAdjusters.lastInMonth(DayOfWeek) methods are part of the java.time.temporal.TemporalAdjusters class. They adjust the date to the first or last occurrence of the specified DayOfWeek in the month. Here’s an example of how to use these methods: package org.kodejava.datetime; import java.time.DayOfWeek; import java.time.LocalDate; import java.time.temporal.TemporalAdjusters; public class FirstLastInMonthExample { public static...
JAVA 8 / CATATAN</>↗Java 817 Jan 2024
The TemporalAdjusters.firstDayOfYear() and TemporalAdjusters.firstDayOfNextYear() methods in Java are utilized to adjust a date to the first day of the current year and the first day of the next year respectively. Here’s how to use these methods: package org.kodejava.datetime; import java.time.LocalDate; import java.time.temporal.TemporalAdjusters; public class FirstDayOfYearExample { public static void main(String[] args) { // Det the […]
JAVA 8 / CATATAN</>↗Java 817 Jan 2024
The TemporalAdjusters.firstDayOfNextMonth() method is a useful method in java.time.temporal.TemporalAdjusters class in Java that adjusts the date to the first day of the next month. Here’s an example usage: package org.kodejava.datetime; import java.time.LocalDate; import java.time.temporal.TemporalAdjusters; public class FirstDayOfNextMonthExample { public static void main(String[] args) { // Get the current date LocalDate date = LocalDate.now(); // Adjust […]