Posts

Showing posts from 2026

Understanding Epoch Time in Java & Spring Boot

Image
  Understanding Epoch Time in Java & Spring Boot 1. What Is Epoch Time? Epoch time (also known as Unix time ) is a numeric representation of time. It is defined as the number of seconds or milliseconds that have elapsed since : January 1, 1970, 00:00:00 UTC This reference point is called the Unix Epoch . Examples ·        0 → 1970-01-01 00:00:00 UTC ·        1700000000 → Epoch time in seconds ·        1700000000000 → Epoch time in milliseconds (commonly used in Java) Key Characteristics ·        Always based on UTC ·        Does not contain timezone information ·        Easy to store, compare, and sort ·        Widely used in APIs, databases, logs, and Kafka events 2. Epoch Time in Java / Spring Boot Java (8+) provides the mo...

Aspect-Oriented Programming (AOP) in Spring Boot

Aspect-Oriented Programming (AOP) in Spring Boot What is AOP? Aspect-Oriented Programming (AOP) is a programming paradigm that allows you to separate cross-cutting concerns from your business logic. Cross-cutting concerns are functionalities that affect multiple parts of an application, such as: Logging Security Transaction management Database routing Performance monitoring Understanding @Aspect and @Order(0) @Aspect Marks a class as an aspect - a modular unit of cross-cutting concern. It contains advice (code to execute) and pointcuts (where to execute). @Order(0) Defines the execution priority when multiple aspects target the same method: Lower numbers = Higher priority @Order(0) executes before @Order(1) , @Order(2) , etc. In this case, routing happens before Spring's @Transactional processing DataSourceRoutingAspect Explained @Aspect @Component @Order(0) // Execute BEFORE @Transactional aspect @Log4j2 public class DataSource...