Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GRAD2-2799-P3 GRAD Incident: REGALG is creating SCCP certificates for… #661

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.time.Period;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;

public class EducGradStudentApiUtils {
Expand Down Expand Up @@ -107,10 +108,10 @@ public static HttpHeaders getHeaders (String accessToken)

public static String parsingTraxDate(String sessionDate) {
String actualSessionDate = sessionDate + "/01";
Date temp = new Date();
Date temp;
String sDates = null;
try {
temp = EducGradStudentApiUtils.parseDate(actualSessionDate, "yyyy/MM/dd");
temp = toLastDayOfMonth(EducGradStudentApiUtils.parseDate(actualSessionDate, "yyyy/MM/dd"));
sDates = EducGradStudentApiUtils.formatDate(temp, EducGradStudentApiConstants.DEFAULT_DATE_FORMAT);
} catch (ParseException pe) {
logger.error("ERROR: {}", pe.getMessage());
Expand All @@ -136,7 +137,7 @@ public static Date parsingProgramCompletionDate(String sessionDate) {
Date temp;
Date sDate = null;
try {
temp = EducGradStudentApiUtils.parseDate(actualSessionDate, EducGradStudentApiConstants.DATE_FORMAT);
temp = toLastDayOfMonth(EducGradStudentApiUtils.parseDate(actualSessionDate, EducGradStudentApiConstants.DATE_FORMAT));
String sDates = EducGradStudentApiUtils.formatDate(temp, EducGradStudentApiConstants.DATE_FORMAT);
sDate = EducGradStudentApiUtils.parseDate(sDates, EducGradStudentApiConstants.DATE_FORMAT);
} catch (ParseException pe) {
Expand Down Expand Up @@ -188,4 +189,11 @@ public static GradStatusEventPayloadDTO transform(GraduationStudentRecordEntity
.build();
}

private static Date toLastDayOfMonth(Date date) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
return cal.getTime();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;

import static ca.bc.gov.educ.api.gradstudent.util.EducGradStudentApiConstants.SECOND_DEFAULT_DATE_FORMAT;

Expand Down Expand Up @@ -40,7 +41,7 @@ public LocalDate deserialize(JsonParser jsonParser, DeserializationContext deser
if(slashCount > 0) {
formatter = DateTimeFormatter.ofPattern(SECOND_DEFAULT_DATE_FORMAT);
}
return LocalDate.parse(dateAsString, formatter);
return LocalDate.parse(dateAsString, formatter).with(TemporalAdjusters.lastDayOfMonth());
} else if(jsonParser.hasToken(JsonToken.VALUE_NUMBER_INT)) {
long timestamp = jsonParser.getValueAsLong();
return LocalDate.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;

import static ca.bc.gov.educ.api.gradstudent.util.EducGradStudentApiConstants.*;

Expand Down Expand Up @@ -41,7 +42,7 @@ public LocalDateTime deserialize(JsonParser jsonParser, DeserializationContext d
if(slashCount > 0) {
formatter = DateTimeFormatter.ofPattern(SECOND_DEFAULT_DATE_FORMAT);
}
return LocalDateTime.parse(dateAsString, formatter);
return LocalDateTime.parse(dateAsString, formatter).with(TemporalAdjusters.lastDayOfMonth());
} else if(jsonParser.hasToken(JsonToken.VALUE_NUMBER_INT)) {
long timestamp = jsonParser.getValueAsLong();
return LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault());
Expand Down
Loading