This annotation must be specified for persistent fields or properties like java.util.Date and java.util.Calendar . It can only be specified for fields or properties of these types.
The Temporal annotation can be used in combination with the Basic annotation, Id annotation, or ElementCollection annotation (when the value of the element set is of such a temporary type.
In simple Java APIs, the time accuracy of time is not defined. When working with temporary data, you can describe the expected accuracy in the database. Temporary data may have a DATE, TIME, or TIMESTAMP precision (i.e., Actual date, time only, or both). For fine tuning, use the @Temporal annotation.
Time data is time related data. For example, in a content management system, the creation date and the date of the last update of an article are temporary data. In some cases, the temporary data needs accuracy, and you want to save the exact date / time or both ( TIMESTAMP ) in the database table.
Temporary accuracy is not specified in the core Java APIs. @Temporal is a JPA annotation that converts back and forth between a timestamp and java.util.Date . It also converts time-stamp to time. For example, in the @Temporal(TemporalType.DATE) snippet below , the time value is reduced and only the date is saved .
@Temporal(TemporalType.DATE) private java.util.Date creationDate;
According to javadocs,
Annotations for declaring the corresponding {@code TemporalType} request method parameters. Please note that this annotation can only be used for parameters like {@link Date} with the default TemporalType.DATE
[Information collected from various sources]
Ankur Singhal Aug 16 '14 at 6:38 a.m. 2014-08-16 06:38 a.m.
source share