diff --git a/demo/.idea/.gitignore b/demo/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/demo/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/demo/src/main/java/com/example/demo/Dto/UserDTO.java b/demo/src/main/java/com/example/demo/Dto/UserDTO.java index 83a00ab..bf76927 100644 --- a/demo/src/main/java/com/example/demo/Dto/UserDTO.java +++ b/demo/src/main/java/com/example/demo/Dto/UserDTO.java @@ -1,16 +1,21 @@ package com.example.demo.Dto; import java.text.DateFormat; +import java.text.ParseException; import java.text.SimpleDateFormat; +import java.time.format.DateTimeFormatter; import java.util.Date; +import java.util.Locale; + import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; public class UserDTO { private String name; private String password; - private String dateCreate; + private Date dateCreate; + private final SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yy"); public UserDTO() { } @@ -20,10 +25,9 @@ public class UserDTO { @JsonProperty(value = "name") String name, @JsonProperty(value = "dateCreate") String dateCreate, @JsonProperty(value = "password") String password - ) - { + ) throws ParseException { this.name = name; - this.dateCreate = dateCreate; + this.dateCreate = formatter.parse(dateCreate); this.password = password; } @@ -32,7 +36,7 @@ public class UserDTO { } public String getDateCreate() { - return dateCreate; + return formatter.format(dateCreate); } public String getPassword() {