Home » Java » Core Java » Page 2

Core Java

Java – Get Time In MilliSeconds

A quick guide to get the current date time in milliseconds using Date, Calendar and java 8 api classes. 1. Overview In this tutorial, We’ll learn how to get the time in milliseconds in java. Time in milliseconds is the right way and format in storing into the database for date time columns. Because this is stored as Number type ...

Read More »

Java Program To Check Palindrome String Using Recursion

A quick guide to check the string is palindrome or not using recursion in java. 1. Overview In this tutorial, We’ll learn how to check the string is palindrome using Recursive function in java. String palindrome means if the string reversed value is equal to the original string. Recursion means calling the one function from the same function. This is ...

Read More »

Converting Between LocalDate and SQL Date In Java 8

A quick guide to convert between LocalDate and java.sql.Date objects in java 8 with examples. 1. Overview In this tutorial, We’ll learn how to convert java.time.LocalDate to java.sql Date in java 8 and vice versa. This is simple to do but when working jpa framework it is bit different to deal with the table column type. First look at the ...

Read More »

Introduction to GraalVM (Community Edition): Revolution or Evolution?

1. Introduction Over the last couple of years we have witnessed the astonishing pace and scale of the innovations in the JVM ecosystem. Not only the new JDK release is coming out every 6 months, research and development are accelerating without any signs of lacking directions and features. Table Of Contents 1. Introduction 2. What Is GraalVM? 3. Evolution or ...

Read More »

ThreadLocal in Java – Example Program and Tutorial

ThreadLocal in Java is another way to achieve thread-safety apart from writing immutable classes. If you have been writing multi-threaded or concurrent code in Java then you must be familiar with the cost of synchronization or locking which can greatly affect the Scalability of application, but there is no choice other than synchronizing if you are sharing objects between multiple ...

Read More »

Java Extension Methods

Whither Extension Methods? Apparently, there’s a java dialect called XTend which does this, but there’s no obvious equivalent of extension methods in Java. An extension method, as I recall from C#, allows you to define something like this: 01 02 03 04 05 06 07 08 09 10 11 int myExtensionMethod(SomeClass theExtendee, Object input) {    return ...; } SomeClass myExtendable ...

Read More »

Overview of implementing Distributed Locks

As we know, locks are generally used to monitor and control access to shared resources by multiple threads at the same time. They basically protect data integrity and atomicity in concurrent applications i.e. Only one thread at a time can acquire a lock on shared resource which otherwise is not accessible. But a lock in distributed environment is more than ...

Read More »

JDK 16: Checking Indexes and Ranges of Longs

In my last post, I described the day period support added with JDK 16 Early Access Build 25. That same build also added methods for checking indexes and ranges of long values, which is the subject of this post. JDK-8255150 (“Add utility methods to check long indexes and ranges”) is the Enhancement used to add utility methods for checking long ...

Read More »

Static Factories are Great!

Every now and then I jump on classes with multiple constructors or classes that are rigorous to work with. Let alone not being able to mock part of their components and at the end being forced to use reflection for testing (mockito based, old school, you choose). Imagine a Producer class that you use for Kafka. A class that provides ...

Read More »