@CreatedDate and @LastModifiedDate

The @CreatedDate and @LastModifiedDate annotation is part of the Spring Data Commons library and is commonly used in conjunction with Spring Data JPA. They are used to automatically populate a field with the current date and time when an entity is created and persisted. This annotation is typically applied to a field in your entity class to represent the creation timestamp.

Here's a basic example of how you might use @CreatedDate:

import org.springframework.data.annotation.CreatedDate;

import javax.persistence.*;
import java.util.Date;

@Entity
public class MyEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    // Other fields...

    @CreatedDate
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "created_date", nullable = false, updatable = false)
    private Date createdDate;

    // Constructors, getters, setters...
}