Compare Two LocalDate Instances in Java
Learn to compare two LocalDate instances to find out which date represents an older date in comparison to second date. LocalDate class is part of java.time package added in Java 8.
Learn to compare two LocalDate instances to find out which date represents an older date in comparison to second date. LocalDate class is part of java.time package added in Java 8.
Learn to execute the cURL commands from Windows. Beginning in Insider Build 17063, Tar and curl are available from the command-line for all SKUs of Windows.
In this Spring security oauth2 tutorial, learn to build an authorization server to authenticate your identity to provide access_token, which you can use to request data from resource server.
The AtomicInteger class protects an underlying int value by providing methods that perform atomic operations on the value. It shall not be used as a replacement for an Integer class.
Learn to format date and time in either 12 hours pattern. The formatted date string will have the AM/PM information as applicable to the timestamp.
Java examples to format LocalDate to String using inbuilt and custom patterns using FormatType and format(formatter) API.
Java programs to find if a given year is a leap year using new Java 8 APIs (LocalDate and Year), legacy Java 7 GregorianCalendar, and custom code.
Learn to compare two instances of ZonedDateTime either in the same timezone or in different timezones in Java 8. 2. Comparing at Same Instant As we know an instance of ZonedDateTime is a point in the universal timeline with an offset. So to compare two such instances, logically, both instances …
Learn to format a ZonedDateTime to string using ZonedDateTime.format (DateTimeFormatter) method in Java 8. Convert ZonedDateTime to String example.
Learn to convert from LocalDate to ZonedDateTime and from ZonedDateTime to LocalDate in Java 8. As we know, LocalDate represents a calendar date without the time and the zone information. ZonedDateTime instance contains all three information i.e. date, time and zone. ZonedDateTime = LocalDate + time + timezone 1. LocalDate …
Learn to convert from LocalDate to LocalDateTime and from LocalDateTime to LocalDate in Java 8.
Java 8 ZonedDateTime class represents an instant in the universal timeline with the timezone information. In this tutorial, we will learn to parse a string to ZonedDateTime object using its parse() method. 1. Parsing a Date Time with ZonedDateTime.parse() Java program to convert a given string into ZonedDateTime instance. After …
Java LocalDateTime class represents an instant in local timeline i.e. without any timezone id. Learn to convert string to LocalDateTime.
Java LocalDate class represents a calendar date without time (hour/minute/seconds) and timezone information. Learn to convert a string to LocalDate object in Java.
Learn about the ZonedDateTime class in Java, how to create its instances and other use cases such as parsing, formatting and adding duration and periods.
Learn about the LocalDateTime class in Java, how to create its instances and other use cases such as parsing, formatting and adding duration and periods. 1. Overview java.time.LocalDateTime class, introduced in Java 8 Date Time API, represents a date and time object without a timezone often viewed as ‘year-month-day-hour-minute-second‘. It …
Learn to create and use the LocalTime class in Java. Learn how to create LocalTime, parse and format the LocalTime instances, including common operations such as adding or subtracting hours from a given time.
Learn about the LocalDate class in Java, how to create its instances and other use cases such as parsing, formatting and adding duration and periods.
Learn to filter a stream of items for multiple if-else style conditions using complex predicates and process filtered items as required.
Learn to join a stream of strings with a delimiter, prefix, and suffix using Collectors.joining(), String.join(), and append elements using StringBuilder.
The Java 8 Stream.concat() method merges two streams into one stream. The combined stream consists of all the elements of both streams.
Java 8 example to sort stream of objects by multiple fields using comparators and Comparator.thenComparing() method. This method returns a lexicographic-order comparator with another comparator. It gives the same effect as SQL group by clause.
Learn to sort stream of numbers and strings in ascending (natural order) and descending orders (reverse order) using Stream.sorted() method.
Learn to create generic functional interfaces with and without type restrictions in Java. Learn to create specialized functional interfaces.
Learn to convert stream to list using Collectors.toList() and Collectors.toCollection() APIs. This post contains multiple examples for collecting stream elements to list under different usecases.
Learn to convert stream to array using Stream.toArray() API. This post contains multiple examples for collecting stream elements to array under different usecases.
Learn to collect Stream items into Map using Collectors.toMap() and Collectors.groupingBy() when Map keys are distinct or duplicates.
Java streams cannot be reused. Once a terminal operation is performed on a stream, it is considered consumed and cannot be reused.
Java Stream has two methods findFirst() and findAny() for retrieving elements. Learn the difference between both methods in parallel streams with examples.
Java Stream noneMatch(predicate) is a short-circuiting terminal operation to check if no element in the stream matches the given predicate.
Java Stream allMatch() is a short-circuiting terminal operation that is used to check if all the elements in the stream satisfy the provided predicate. 1. Stream allMatch() Method 1.1. Syntax Here predicate a non-interfering, stateless predicate to apply to all the elements of the stream. The allMatch() method returns always …
Java Stream anyMatch (Predicate predicate) is terminal-short-circuiting operation which is used to check if the stream contains any matching element with provided predicate.
Java 8 examples to create an infinite stream of elements. We will use Stream’s generate() and iterate() methods to get the infinite streams.
Java Stream skip(n) method returns a new stream consisting of the remaining elements of this stream, after the n elements have been skipped.
We can use Stream.limit(long) to retrieve elements while they must not be greater than a certain maximum count. Java 8 Stream limit() example
Java 8 Stream interface has peek(Consumer action) method which returns a new stream consists of all the elements of original stream after applying the method argument Consumer action.
The difference between map() vs flatMap() with example. map() is used for transformation only, but flatMap() is used for both transformation and flattening.
Learn to use Java Stream flatMap() method which is used to flatten a stream of collections to a stream of elements combined from all collections.
Learn to use Java Stream map() method which produces one output value of a different type ‘X’ for each input value of type ‘Y’.
Learn to use Stream min() method to select the smallest element in the stream according to the comparator provided in its argument.
Learn to use Java Stream max() method to select the largest element in the stream according to the comparator provided in its argument.
Learn to use Stream sorted() method to sort a stream of elements in their natural order and also according to the provided Comparator.
Java examples of chained predicates and to perform ‘logical AND‘ and ‘logical OR‘ operations and collect the elements into a list.
Java 8 predicate negate() returns a predicate that is the logical negation of this predicate. Java 11 introduced not() which is also the same.
Learn to use Stream.filter(Predicate) method to traverse all the elements and filter all items which match a given condition through Predicate argument. 1. Stream filter() Method The stream() method syntax is as follows: Predicate is a functional interface and represents the condition to filter out the non-matching elements from the …
Learn to use Stream.forEachOrdered(Consumer action) method to traverse all the elements and performs an action for each element of this stream, in the encounter order of the stream if the stream has a defined encounter order.
Learn to use Stream forEach(Consumer action) method to traverse all the elements of stream and performs an action for each element of this stream.
Learn to create Streams of primitives and objects in Java using some most popular ways. We will learn to create finite as well as infinite streams.
In this spring webflux websocket example, Learn to create reactive applications which support persistent websocket connection between a client and server.
In this spring webflux tutorial, we will learn the basic concepts behind reactive programming, webflux apis and a fully functional hello world example.
HowToDoInJava provides tutorials and how-to guides on Java and related technologies.
It also shares the best practices, algorithms & solutions and frequently asked interview questions.