Skip to content

Commit d38020d

Browse files
authored
Merge pull request boylegu#16 from boylegu/issue/14/resolve_timestamp
close boylegu#14 handle timestamp problem
2 parents e498772 + 70fe97c commit d38020d

File tree

5 files changed

+27
-20
lines changed

5 files changed

+27
-20
lines changed

frontend/src/components/DbTable.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@
130130
},
131131
132132
formatter(row, column) {
133-
let data = this.$moment.unix(row.create_datetime);
134-
return data.format('YYYY-MM-DD HH:mm:ss')
133+
let data = this.$moment(row.create_datetime, this.$moment.ISO_8601);
134+
return data.format('YYYY-MM-DD')
135135
},
136136
}
137137
}

info.db

0 Bytes
Binary file not shown.

schema_data.sql

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@
33
*/
44

55

6-
CREATE TABLE persons (id integer, create_datetime datetime, email varchar(255), phone varchar(255), sex varchar(255), username varchar(255), zone blob, primary key (id));
6+
/* CREATE TABLE persons (id integer, create_datetime datetime, email varchar(255), phone varchar(255), sex varchar(255), username varchar(255), zone blob, primary key (id));
7+
*/
8+
79

810
INSERT INTO persons (create_datetime, email, phone, sex, username, zone) VALUES (datetime('now'), '[email protected]', 08613000001111, 'male', 'gubaoer', 'HongKou District');
911

1012
INSERT INTO persons (create_datetime, email, phone, sex, username, zone) VALUES (datetime('now'), '[email protected]', 08613000001112, 'male', 'baoer.gu', 'JingAn District');
1113

12-
INSERT INTO persons (create_datetime, email, phone, sex, username, zone) VALUES (datetime('now'), '[email protected]', 08613000001113, 'fmale', 'yoyo.wu', 'JingAn District');
14+
INSERT INTO persons (create_datetime, email, phone, sex, username, zone) VALUES (datetime('now'), '[email protected]', 08613000001113, 'female', 'yoyo.wu', 'JingAn District');
1315

14-
INSERT INTO persons (create_datetime, email, phone, sex, username, zone) VALUES (datetime('now'), '[email protected]', 08613000001114, 'fmale', 'stacy.gao', 'MinHang District');
16+
INSERT INTO persons (create_datetime, email, phone, sex, username, zone) VALUES (datetime('now'), '[email protected]', 08613000001114, 'female', 'stacy.gao', 'MinHang District');
1517

16-
INSERT INTO persons (create_datetime, email, phone, sex, username, zone) VALUES (datetime('now'), '[email protected]', 08613000001115, 'fmale', 'yomiko.zhu', 'PuDong District');
18+
INSERT INTO persons (create_datetime, email, phone, sex, username, zone) VALUES (datetime('now'), '[email protected]', 08613000001115, 'female', 'yomiko.zhu', 'PuDong District');
1719

1820
INSERT INTO persons (create_datetime, email, phone, sex, username, zone) VALUES (datetime('now'), '[email protected]', 08613000001116, 'male', 'hong.zhu', 'YangPu District');
1921

@@ -23,12 +25,12 @@ INSERT INTO persons (create_datetime, email, phone, sex, username, zone) VALUES
2325

2426
INSERT INTO persons (create_datetime, email, phone, sex, username, zone) VALUES (datetime('now'), '[email protected]', 08613000001119, 'male', 'wen.liu', 'ChongMing District');
2527

26-
INSERT INTO persons (create_datetime, email, phone, sex, username, zone) VALUES (datetime('now'), '[email protected]', 08613000001120, 'fmale', 'cai.lu', 'BaoShan District');
28+
INSERT INTO persons (create_datetime, email, phone, sex, username, zone) VALUES (datetime('now'), '[email protected]', 08613000001120, 'female', 'cai.lu', 'BaoShan District');
2729

2830
INSERT INTO persons (create_datetime, email, phone, sex, username, zone) VALUES (datetime('now'), '[email protected]', 08613000001121, 'male', 'alex.li', 'ChangNing District');
2931

30-
INSERT INTO persons (create_datetime, email, phone, sex, username, zone) VALUES (datetime('now'), '[email protected]', 08613000001122, 'fmale', 'sofia.xu', 'ZhaBei District');
32+
INSERT INTO persons (create_datetime, email, phone, sex, username, zone) VALUES (datetime('now'), '[email protected]', 08613000001122, 'female', 'sofia.xu', 'ZhaBei District');
3133

32-
INSERT INTO persons (create_datetime, email, phone, sex, username, zone) VALUES (datetime('now'), '[email protected]', 08613000001123, 'fmale', 'cora.zhang', 'XuHui District');
34+
INSERT INTO persons (create_datetime, email, phone, sex, username, zone) VALUES (datetime('now'), '[email protected]', 08613000001123, 'female', 'cora.zhang', 'XuHui District');
3335

34-
INSERT INTO persons (create_datetime, email, phone, sex, username, zone) VALUES (datetime('now'), '[email protected]', 08613000001124, 'fmale', 'tom.gao', 'HuangPu District');
36+
INSERT INTO persons (create_datetime, email, phone, sex, username, zone) VALUES (datetime('now'), '[email protected]', 08613000001124, 'female', 'tom.gao', 'HuangPu District');

src/main/java/com/boylegu/springboot_vue/entities/Persons.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
11
package com.boylegu.springboot_vue.entities;
22

33
import javax.persistence.*;
4-
import java.util.Date;
54
import java.io.Serializable;
65

7-
import org.springframework.format.annotation.DateTimeFormat;
8-
96

107
@Entity
118
@Table(name = "persons")
129
public class Persons implements Serializable {
10+
1311
@Id
1412
@GeneratedValue(strategy = GenerationType.AUTO)
15-
1613
private long id;
14+
1715
@Column(name = "create_datetime")
18-
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
19-
private Date create_datetime;
16+
/*
17+
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
18+
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ", locale = "zh", timezone = "UTC")
19+
@Type(type="datetime")
20+
*/
21+
private String create_datetime;
22+
2023
@Column(name = "username")
2124
private String username;
25+
2226
@Column(name = "email")
2327
private String email;
28+
2429
@Column(name = "phone")
2530
private String phone;
31+
2632
@Column(name = "sex")
2733
private String sex;
34+
2835
@Column(name = "zone")
2936
private String zone;
3037

@@ -36,12 +43,12 @@ public void setId(long id) {
3643
this.id = id;
3744
}
3845

39-
public Date getCreate_datetime() {
46+
public String getCreate_datetime() {
4047
return create_datetime;
4148

4249
}
4350

44-
public void setCreate_datetime(Date create_datetime) {
51+
public void setCreate_datetime(String create_datetime) {
4552
this.create_datetime = create_datetime;
4653
}
4754

src/main/resources/application.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ debug=true
22
spring.output.ansi.enabled=DETECT
33
server.port = 8000
44

5-
# spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
6-
75
spring.jpa.properties.hibernate.hbm2ddl.auto=update
86
spring.datasource.url=jdbc:sqlite:info.db
97
spring.datasource.driver-class-name = org.sqlite.JDBC

0 commit comments

Comments
 (0)