UTIL PACKAGE / NOTES</>↗Util Package20 Jan 2024
The java.util.Base64.getEncoder() and java.util.Base64.getUrlEncoder() methods in Java both return a Base64 encoder. However, they exhibit different behaviors mainly due to the encoding scheme they follow for handling URL and filename safe characters. java.util.Base64.getEncoder(): This method returns a Base64.Encoder that encodes using the Basic type base64 encoding scheme as per RFC 4648 Section 4. Basic Base64 […]
JAVA 8 / NOTES</>↗Java 820 Jan 2024
You can use the atStartOfDay() method from LocalDate class to convert a LocalDate into a LocalDateTime. Then, you need to convert LocalDateTime to a ZonedDateTime using the atZone() method. Here is an example: package org.kodejava.datetime; import java.time.*; public class LocalDateToZonedDateTimeExample { public static void main(String[] args) { // Create a LocalDate LocalDate date = LocalDate.of(2023, […]
JAVA 8 / NOTES</>↗Java 820 Jan 2024
The ZonedDateTime class is part of the Java Date-Time Package (java.time.*), released in Java 8 to address the shortcomings of the old date-time classes such as java.util.Date, java.util.Calendar, and java.util.SimpleDateFormat. Some of the key features are: It represents a date-time with a timezone in the ISO-8601 calendar system, such as ‘2007-12-03T10:15:30+01:00 Europe/Paris’. It provides a […]
JAVA 8 / NOTES</>↗Java 819 Jan 2024
The ZoneRules class in Java’s Date-Time API is used to encapsulate the set of rules defining how the zone offset varies for a single time zone. The information in this class is typically derived from the IANA Time Zone Database (TZDB). The rules model the data traditionally contained in the ‘zic’ compiled data files of […]
JAVA 8 / NOTES</>↗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 / NOTES</>↗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 […]