In this post under JAX-RS Client, I will show with example how to extend base URL with path segments. Suppose you want to access below two REST apis. These two apis return user information with id 2 and 3. https://jsonplaceholder.typicode.com/users/2https://jsonplaceholder.typicode.com/users/3 To access these two urls you will create two “WebTarget” instances as shown below WebTarget…… Continue reading Extending base URL with path segments
Author: sumanthprabhakar
JAX-RS Client API simple DELETE example
In this post under JAX-RS Client, I will show with example how to perform a DELETE REST call. Below is the complete code for your reference Main Class 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 import jakarta.ws.rs.core.Response; 8 9 public class Example4 { 10 public…… Continue reading JAX-RS Client API simple DELETE example
JAX-RS Client API simple PUT example
In this post under JAXRS Client, I will show with simple example how to use the JAXRS Client API to make a PUT request to REST api resource. Below is the complete code for the example Main class 1 package defaultPackage; 2 3 import jakarta.ws.rs.client.Client; 4 import jakarta.ws.rs.client.ClientBuilder; 5 import jakarta.ws.rs.client.Entity; 6 import jakarta.ws.rs.client.Invocation; 7…… Continue reading JAX-RS Client API simple PUT example
JAX-RS Client API simple POST example
In this post under JAXRS Client section, I will show with simple example how to use the JAXRS Client API to make a POST request to REST api resource. Below is the complete code for the example Main class 1 package defaultPackage; 2 3 import jakarta.ws.rs.client.Client; 4 import jakarta.ws.rs.client.ClientBuilder; 5 import jakarta.ws.rs.client.Entity; 6 import jakarta.ws.rs.client.Invocation;…… Continue reading JAX-RS Client API simple POST example
Converting Date instance to Instant instance
In this post under DateTime, I will show how to convert an instance of “Date” class to “Instant” instance. Below is the code to that will do the conversion. Date date = new Date(); Instant instant = date.toInstant(); As shown in the above code snippet, first we create a “Date” instance and store in “date”…… Continue reading Converting Date instance to Instant instance
Converting Instant instance to Date instance
In this post under DateTime, I will show how to convert an instance of “Instant” class to “Date” instance. Below is the code to that will do the conversion. Instant instant = Instant.now(); Date date = Date.from(instant); “now” static method of “Instant” class will return an “Instant” instance representing the current date time. Then we…… Continue reading Converting Instant instance to Date instance
Serializing and De-Serializing Date object to and from a custom pattern
In this post under Java, I will show with example how to serialize and de-serialize Date object using a custom pattern. In the previous post, we used “SimpleDateFormat” class to serialize and de-serialize Date object using a pattern obtained based on system default locale. This pattern was figured out by Java and was not provided…… Continue reading Serializing and De-Serializing Date object to and from a custom pattern
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)