Java – Display list of TimeZone with GMT
This Java example shows you how to display a list of TimeZone with GMT in front.
Java – Display all ZoneId and its UTC offset
A Java 8 example to display all the ZoneId and its OffSet hours and minutes.
Java 8 – Convert LocalDateTime to Timestamp
In Java, we can use Timestamp.valueOf(LocalDateTime) to convert a LocalDateTime into a Timestamp. Java example to convert java.time.LocalDateTime to java.sql.Timestamp and vice verse.
Java 8 – Convert ZonedDateTime to Timestamp
Java example to convert java.time.ZonedDateTime to java.sql.Timestamp and vice verse. 1. ZonedDateTime -> Timestamp TimeExample1.java Output 2. Timestamp -> ZonedDateTime TimeExample2.java Output Download Source Code $ git clone https://github.com/favtuts/java-core-tutorials-examples $…
How to change the JVM default locale?
In Java, we can use Locale.setDefault() to change the JVM default locale. Alternatively, in the command line, we can configure the user.country and user.language system property to change the JVM…
Java 8 – How to parse date with LocalDateTime
Here are a few Java 8 examples to parse date with LocalDateTime. First, find the DateTimeFormatter pattern that matches the date format, second, parse it with LocalDateTime.parse
Java 8 – Unable to obtain LocalDateTime from TemporalAccessor
An example of converting a String to LocalDateTime, but it prompts the following errors: Unable to obtain LocalDateTime from TemporalAccessor: {},ISO resolved to 2020-08-31 of type java.time.format.Parsed . The date…
Java 8 – How to parse date with “dd MMM” (02 Jan), without year?
This example shows you how to parse a date (02 Jan) without a year specified. The pattern dd MMM is not enough; we need a DateTimeFormatterBuilder to provide a default…
Java 8 – How to calculate days between two dates?
In Java 8, we can use ChronoUnit.DAYS.between(from, to) to calculate days between two dates, for both LocalDate and LocalDateTime.
Java 8 – Convert Epoch time milliseconds to LocalDate or LocalDateTime
In Java 8, we can use Instant.ofEpochMilli().atZone() to convert the epoch time in milliseconds back to LocalDate or LocalDateTime