How to convert LocalDateTime to OffsetDateTime?

There are many ways to convert LocalDateTime to OffsetDateTime. Some of them are listed below: 1. Using LocalDateTime#atOffset​(ZoneOffset offset): LocalDateTime ldt = LocalDateTime.now(); ZoneOffset offset = ZoneOffset.UTC; OffsetDateTime odt = ldt.atOffset(offset); 2. Using LocalDateTime#atZone​(ZoneId zone) => ZonedDateTime#toOffsetDateTime(): LocalDateTime ldt = LocalDateTime.now(); // Change the ZoneId as required e.g. ZoneId.of(“Europe/London”) ZoneId zoneId = ZoneId.systemDefault(); OffsetDateTime odt … Read more

Java 8 Streams peek api

The Javadoc mentions the following: Intermediate operations return a new stream. They are always lazy; executing an intermediate operation such as filter() does not actually perform any filtering, but instead creates a new stream that, when traversed, contains the elements of the initial stream that match the given predicate. Traversal of the pipeline source does … Read more

Automatic replacing all anonymous inner class to lambda in Intellij Idea

In the Analyze menu, select “Run Inspection by Name…”. In the search box, type “Anonymous” and select the one that says “Anonymous class may be replaced by lambda” or something to that effect. Select your scope and start the analysis. In the results, you can inspect them individually and click the “Replace with lambda” link … Read more

Java 8 update 151 or 152? [duplicate]

The general idea is that 8u151 (tag jdk8u151-b12) is a Critical Patch Update (CPU) Release 8u152 (tag jdk8u152-b16) is a Patch Set Update (PSU) Release From official Oracle CPU and PSU Releases Explained Starting with the release of Java SE 7 Update 71 (Java SE 7u71) in October 2014, Oracle will release a Critical Patch … Read more