Guide to Guava ClassToInstanceMap 1. Overview A ClassToInstanceMap<B> is a special kind of map that associates classes with corresponding instances. It makes sure that all the keys and the values are subtypes of the upper bound type B. ClassToInstanceMap extends Java’s Map interface and provides two additional methods: T getInstance(Class<T>)… Continue Reading guava-class-to-instance-map

Custom Error Message Handling for REST API 1. Overview In this tutorial – we’ll discuss how to implement an global error handler for a Spring REST API. We will use the semantics of each exception to build out meaningful error messages for client, with the clear goal of giving that… Continue Reading global-error-handler-in-a-spring-rest-api

Get the Current Date, Time and Timestamp in Java 8 1. Introduction This quick article describes how we may get the current date, current time and current time stamp in Java 8. 2. Current Date First, let’s use java.time.LocalDate to get the current system date: LocalDate localDate = LocalDate.now(); To… Continue Reading current-date-time-and-timestamp-in-java-8