Java 8 – Convert Instant to ZonedDateTime
Java 8 examples to show you how to convert from Instant to ZonedDateTime. Example to convert a Instant UTC+0 to a Japan ZonedDateTime UTC+9. Convert the Japan ZonedDateTime UTC+9 back…
Java 8 – Convert Instant to LocalDateTime
Java 8 examples to show you how to convert from Instant to LocalDateTime and vice versa. The java.time.LocalDateTime has no concept of time zone, just provide a zero offset UTC+0.
Java 8 – Period and Duration examples
Few examples to show you how to use Java 8 Duration, Period and ChronoUnit objects to find out the difference between dates. Duration – Measures time in seconds and nanoseconds.…
How to convert String to Date – Java
In this tutorial, we will show you how to convert a String to java.util.Date. Many Java beginners are stuck in the Date conversion, hope this summary guide will helps you…
Java JDBC Tutorials
The Java Database Connectivity (JDBC) API enables Java application to interact with database. 1. Getting Started JDBC + Oracle database JDBC + MySQL database JDBC + PostgreSQL database 2. Statement…
How to get current timestamps in Java
This article shows few Java examples to get the current date time or timestamp in Java. (Updated with Java 8): 1 - uses java.sql.Timestamp to get the current timestamp and…
Java – How to get current date time
In this tutorial, we will show you how to get the current date time from the new Java 8 java.time.* like Localdate, LocalTime, LocalDateTime, ZonedDateTime, Instant and also the legacy…
Java – Stream has already been operated upon or closed
In Java 8, Stream cannot be reused, once it is consumed or used, the stream will be closed. If we reuse the stream it will throw an IllegalStateException, saying “stream…
Java – How to sum all the stream integers
The sum() method is available in the primitive int-value stream like IntStream, not Stream. We can use mapToInt() to convert a stream integers into a IntStream.