Skip to content

Commit

Permalink
Fix date parse for yyyy-MM-ddTHH:mm:ss pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
arybakov-cgi committed Jul 25, 2023
1 parent 36a7b01 commit ae1bcc7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;

Expand All @@ -19,7 +19,7 @@ public class Student implements Serializable {
private String gender;
private String citizenship;
private LocalDate birthdate;
private LocalDateTime lastUpdateDate;
private Date lastUpdateDate;
private Address address;
private String grade;
private String gradProgram;
Expand Down Expand Up @@ -101,11 +101,12 @@ public void setBirthdate(LocalDate value) {
this.birthdate = value;
}

public LocalDateTime getLastUpdateDate() {
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
public Date getLastUpdateDate() {
return lastUpdateDate;
}

public void setLastUpdateDate(LocalDateTime lastUpdateDate) {
public void setLastUpdateDate(Date lastUpdateDate) {
this.lastUpdateDate = lastUpdateDate;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ public class StudentCredentialDistribution {
private String program;
private String studentGrade;
private List<GradRequirement> nonGradReasons;

public LocalDateTime getLastUpdateDate() {
return lastUpdateDate == null ? LocalDateTime.now() : lastUpdateDate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.sql.Date;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
Expand Down Expand Up @@ -218,7 +220,7 @@ private Student prepareStudentObj(StudentCredentialDistribution scd, List<Studen
std.setPen(pen);
std.setGrade(scd.getStudentGrade());
std.setGradProgram(scd.getProgram());
std.setLastUpdateDate(scd.getLastUpdateDate());
std.setLastUpdateDate(Date.from(scd.getLastUpdateDate().atZone(ZoneId.systemDefault()).toInstant()));
std.setGraduationData(new GraduationData());
std.setNonGradReasons(getNonGradReasons(scd.getNonGradReasons()));

Expand Down

0 comments on commit ae1bcc7

Please sign in to comment.