Compare commits

...

1 Commits
main ... lab1

Author SHA1 Message Date
bekodeg
6e1fed20b6 ковертация даты 2024-04-09 15:32:54 +04:00
2 changed files with 17 additions and 5 deletions

8
demo/.idea/.gitignore vendored Normal file
View File

@ -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

View File

@ -1,16 +1,21 @@
package com.example.demo.Dto; package com.example.demo.Dto;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.Date; import java.util.Date;
import java.util.Locale;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
public class UserDTO { public class UserDTO {
private String name; private String name;
private String password; private String password;
private String dateCreate; private Date dateCreate;
private final SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yy");
public UserDTO() { public UserDTO() {
} }
@ -20,10 +25,9 @@ public class UserDTO {
@JsonProperty(value = "name") String name, @JsonProperty(value = "name") String name,
@JsonProperty(value = "dateCreate") String dateCreate, @JsonProperty(value = "dateCreate") String dateCreate,
@JsonProperty(value = "password") String password @JsonProperty(value = "password") String password
) ) throws ParseException {
{
this.name = name; this.name = name;
this.dateCreate = dateCreate; this.dateCreate = formatter.parse(dateCreate);
this.password = password; this.password = password;
} }
@ -32,7 +36,7 @@ public class UserDTO {
} }
public String getDateCreate() { public String getDateCreate() {
return dateCreate; return formatter.format(dateCreate);
} }
public String getPassword() { public String getPassword() {