Skip to content

Commit

Permalink
change JSON date format to yyyy-MM-dd HH:mm:ss
Browse files Browse the repository at this point in the history
  • Loading branch information
YanzheL committed Sep 6, 2019
1 parent b41e72b commit 90c0199
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hemeijia.apigate.persistence.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
Expand All @@ -16,9 +17,11 @@ public abstract class BaseEntity implements Serializable {
@CreationTimestamp
@Column(nullable = false, updatable = false)
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
protected Date createdAt;

@UpdateTimestamp
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
protected Date updatedAt;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hemeijia.apigate.persistence.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
Expand Down Expand Up @@ -38,6 +39,7 @@ public class Coupon extends BaseEntity implements Pricable {
protected boolean paid;

@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
protected Date usedAt;

protected boolean valid = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hemeijia.apigate.persistence.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
Expand Down Expand Up @@ -53,9 +54,11 @@ public class Order extends BaseEntity {
protected String status;

@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
protected Date startAt;

@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
protected Date endAt;

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hemeijia.apigate.web.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
import javax.validation.constraints.NotNull;
import lombok.Data;
Expand All @@ -11,9 +12,11 @@ public class OrderCreateDto {
protected Long couponId;

@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
protected Date startAt;

@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
protected Date endAt;

protected String name;
Expand Down

0 comments on commit 90c0199

Please sign in to comment.