From 6e1fed20b6ee7e50faa617b607ee166fe5eddf33 Mon Sep 17 00:00:00 2001 From: bekodeg Date: Tue, 9 Apr 2024 15:32:54 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BA=D0=BE=D0=B2=D0=B5=D1=80=D1=82=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F=20=D0=B4=D0=B0=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/.idea/.gitignore | 8 ++++++++ .../main/java/com/example/demo/Dto/UserDTO.java | 14 +++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 demo/.idea/.gitignore 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() {