简体   繁体   English

在 Java Spring/Oracle 中将时间戳转换为日期时间格式

[英]Convert Timestamp to Datetime Format in Java Spring/Oracle

I created a table in oracle which automatic add timestamp after add data.我在 oracle 中创建了一个表,它在添加数据后自动添加时间戳。 However, in database the format is like this:但是,在数据库中,格式是这样的:

12/10/2017 11:16:21.000000000

But after it parse from backend to HTML using AngularJS, it shows like this但是在使用 AngularJS 从后端解析为 HTML 之后,它显示如下

1507778181000

Here come my code in bean.java:这是我在 bean.java 中的代码:

    @Column(name="AUDIT_DATE")
    @DateTimeFormat(pattern="yyyy-MM-dd'T'HH:mm:ss")
    private Timestamp auditDate;

May I know is that any method to display that timestamp in a datetime format?我可以知道以日期时间格式显示该时间戳的任何方法吗? Where should I implement that method?我应该在哪里实现该方法? Should I implement the method in Bean/DAO, or I make it in front-end?我应该在 Bean/DAO 中实现该方法,还是在前端实现?

Instead of changing modify the code in Java backend code, I use a built in function in AngularJS called date filter :我没有更改 Java 后端代码中的修改代码,而是在 AngularJS 中使用了一个名为date filter的内置函数:

{{ date | date : format : timezone }}

This is what I did to convert the date to the format that I wanted.这就是我将日期转换为我想要的格式所做的工作。

https://www.w3schools.com/angular/ng_filter_date.asp https://www.w3schools.com/angular/ng_filter_date.asp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM