Hibernate JPA Annotations @Temporal (temporaltype.date) Date annotations!

Source: Internet
Author: User
Tags mongodb postgresql redis firewall


The role of @Temporal tags is simple:



1, if there is a date type of property in a class, the database store may be ' yyyy-mm-dd hh:MM:ss ' to obtain the date and year on the query, the attribute is labeled @temporal (temporaltype.date) will be shaped like ' yyyy-mm-dd ' Format of the date.



DATE: Equals java.sql.Date






Date:



@Temporal (Temporaltype.date)
@Column (name = "Applydate", nullable = false, length = 12)
Public Date getapplydate () {
return applydate;
}



Value at page end: 2016--09--28



2, if there is a date type of property in a class, the database store may be ' yyyy-mm-dd hh:MM:ss ' to obtain seconds and minutes, on which the label @Temporal (Temporaltype.time) will get the shape of the "HH:MM:SS" format of the date.



Time: Equals Java.sql.Time






Time:



@Temporal (Temporaltype.time)



Value at page end: 15:50:30



3, if there is a date type of property in a class, the database store may be ' yyyy-mm-dd hh:MM:ss ' to obtain ' is ' yyyy-mm-dd hh:MM:ss ', the attribute is labeled @Temporal ( Temporaltype.timestamp) will get a date shaped like ' HH:MM:SS ' format



TIMESTAMP: Equals Java.sql.Timestamp



Date and Time (default):






@Temporal (Temporaltype.timestamp)
Value on page: 2016-09-28 15:52:32:000



Control does not display milliseconds in JSP: <TD align= "center" >&nbsp;<fmt:formatdate value= "${list[0].createtime}" pattern= " Yyyy-mm-dd HH:mm:ss "></fmt:formatDate></td>


Alibaba Cloud Hot Products

Elastic Compute Service (ECS) Dedicated Host (DDH) ApsaraDB RDS for MySQL (RDS) ApsaraDB for PolarDB(PolarDB) AnalyticDB for PostgreSQL (ADB for PG)
AnalyticDB for MySQL(ADB for MySQL) Data Transmission Service (DTS) Server Load Balancer (SLB) Global Accelerator (GA) Cloud Enterprise Network (CEN)
Object Storage Service (OSS) Content Delivery Network (CDN) Short Message Service (SMS) Container Service for Kubernetes (ACK) Data Lake Analytics (DLA)

ApsaraDB for Redis (Redis)

ApsaraDB for MongoDB (MongoDB) NAT Gateway VPN Gateway Cloud Firewall
Anti-DDoS Web Application Firewall (WAF) Log Service DataWorks MaxCompute
Elastic MapReduce (EMR) Elasticsearch

Alibaba Cloud Free Trail

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.