Serializing and De-Serializing Date object to and from pattern

In this post, I will show with example how to serialize and deserialize Date object. Java provides “SimpleDateFormat” class to serialize and deserialize Date objects. Below is an example Main class 1 package datetime; 2 3 import java.text.ParseException; 4 import java.text.SimpleDateFormat; 5 import java.util.Date; 6 7 public class Example1 { 8 public static void main(String[]…… Continue reading Serializing and De-Serializing Date object to and from pattern

JAX-RS Client API Simple GET Example

In this post under JAXRS Client, I will show with simple example how to use the JAXRS Client API to make a GET request to REST api resource. Below is the complete code of the example Main Code 1 package defaultPackage; 2 3 import jakarta.ws.rs.client.Client; 4 import jakarta.ws.rs.client.ClientBuilder; 5 import jakarta.ws.rs.client.Invocation; 6 import jakarta.ws.rs.client.WebTarget; 7…… Continue reading JAX-RS Client API Simple GET Example

Configuring ExponentialBackOffPolicy (using annotations)

In this post, under Spring Retry I will show with example how to configure ExponentialBackOffPolicy using annotations. For our example we will use the below service class Service class 1 package defaultPackage; 2 3 import java.util.Date; 4 5 import org.springframework.retry.annotation.Backoff; 6 import org.springframework.retry.annotation.Retryable; 7 import org.springframework.stereotype.Service; 8 9 @Service 10 public class Service15 { 11…… Continue reading Configuring ExponentialBackOffPolicy (using annotations)

Creating and Parsing a asymmetric key signed JWT containing claims

In this post under JJWT, I will show with example how to create and parse asymmetric key signed JWT containing claims. Below is the complete code for your reference. Main class 1 package defaultPackage; 2 import java.security.KeyPair; 3 import java.security.PrivateKey; 4 import java.security.PublicKey; 5 import java.util.Date; 6 7 import io.jsonwebtoken.Claims; 8 import io.jsonwebtoken.Jws; 9 import…… Continue reading Creating and Parsing a asymmetric key signed JWT containing claims

Creating and Parsing a asymmetric key signed JWT containing payload

In this post under JJWT, I will show with example how to create and parse asymmetric key signed JWT containin payload. The JWT can contain claims or payload. For our example we will use a JWT containing payload. Below is the complete code for your reference Main code 1 package defaultPackage; 2 import java.security.KeyPair; 3…… Continue reading Creating and Parsing a asymmetric key signed JWT containing payload

Asserting the presence of a custom claim in JWT

In this post under JJWT, I will explain with example, how to verify or assert the presence of custom (user created and added) claim in JWT token. JJWT framework provides a method through which1) we can verify whether a custom claim exist in the JWT or not.2) we can verify whether a custom claim’s value…… Continue reading Asserting the presence of a custom claim in JWT

Asserting the presence of a standard claim in JWT

In this post under JJWT, I will explain with example, how to verify or assert the presence of standard claim in JWT token. JJWT framework provides a list of methods through which1) we can verify whether a standard claim exist in the JWT or not.2) we can verify whether a standard claim’s value is equal…… Continue reading Asserting the presence of a standard claim in JWT

AssertSame Example

In this post under JUnit, I will show with example the purpose of AssertSame assertion method. JUnit 5 has added new assertion method “assertSame” that checks for Object reference equality. How “assertSame” is different from “assertEquals” assertion method is that latter check for Object value equality whereas former checks for Object reference equality. Object value…… Continue reading AssertSame Example

Configuring UniformRandomBackOffPolicy (using annotations)

In this post, under Spring Retry I will show with example how to configure UniformRandomBackOffPolicy using annotations For our example we will use the below service class Service class 1 package defaultPackage; 2 3 import java.util.Date; 4 5 import org.springframework.retry.annotation.Backoff; 6 import org.springframework.retry.annotation.Retryable; 7 import org.springframework.stereotype.Service; 8 9 @Service 10 public class Service14 { 11…… Continue reading Configuring UniformRandomBackOffPolicy (using annotations)