Java

Contains all the java related examples

Configure Log4j2 Converter Plugin -Java (Filter log messages)

Apache Log4j2 is used for printing info, error, debug, trace logging statements in enterprise applications. Inorder to format all the log messages externally before printing in logs, we need to create Filters in Log4j 1.x versions. In Log4j2 , we can use LogEventPatternConverter to filter/convert/format log messages before printing in the log files in server. …

Configure Log4j2 Converter Plugin -Java (Filter log messages) Read More »

Configure Log4j2 -Java in minutes

Apache Log4j2 is used for printing info, error, debug, trace logging statements in enterprise applications. Apache Log4j2.x is an extension of Log4j1.x which has more significant features comparatively.Since major security vulnerabilities like Log4jShell & hacking possibilities are identified in Log4j1.x, it is always recommended to use Log4j2.x. It is pretty simple to configure Log4j2 in …

Configure Log4j2 -Java in minutes Read More »

SimpleDateFormat (Parse Date)

Date conversions are very common scenarios in any application., Java Provides SimpleDateFormat class for String to Date, Date to String conversions. The below example shows How String format can be converted to Date Format. How to find difference between 2 Dates. Code:

Output

BlockingQueue

BlockingQueue is a thread-safe queue where we can enqueue on one end of queue, and dequeue on another end of queue., All BlockingQueue implementions on array or linked queues are thread-safe implementations. Below is a simple usage of BlockingQueue.

Output:

BlockingDeque

BlockingDeque is an extended implementation of queue where we can enqueue or dequeue on both ends of the queue. All BlockingDeque implementions on array or linked queues are thread-safe implementations. Below is a simple usage of BlockingDeque

Output:

Encoding/Decoding In Java

Encoding/Decoding is the method of representing an data, to a different format so that data can be transferred through the network or web. Encoder usually converts the data into web representation and after received in the other end, decoder converts back the web representation data to original data. 1. Base64 Encoding/Decoding Base64 is a way …

Encoding/Decoding In Java Read More »

Serialization

A Java Class Object needs to serialized if we need to store or transfer with the state values. For any IO operations or network operations usually the java class objects needs to sent/received via network via bytes. During serialization, Object along with state is serialized to bytes and can be processed between the systems as …

Serialization Read More »