Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ac435b6

Browse files
committedMar 17, 2025·
GRAD2-3154 - Adult algorithm +1month rule not fully working as required
1 parent f77b4b6 commit ac435b6

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed
 

‎.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,5 @@ build/
5555
.vscode/
5656

5757
### Local dev ###
58-
**/application-local.yaml
58+
**/application-local.yaml
59+
**/generate-local-env.sh

‎api/src/main/java/ca/bc/gov/educ/api/ruleengine/dto/GradAlgorithmGraduationStatus.java

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
package ca.bc.gov.educ.api.ruleengine.dto;
22

3+
import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils;
4+
import com.fasterxml.jackson.annotation.JsonFormat;
35
import lombok.Data;
46
import org.springframework.stereotype.Component;
57

68
import java.io.Serializable;
7-
import java.sql.Date;
9+
import java.time.LocalDate;
10+
import java.util.Date;
811
import java.util.UUID;
912

13+
import static ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiConstants.DEFAULT_DATE_FORMAT;
14+
1015
@Data
1116
@Component
1217
public class GradAlgorithmGraduationStatus implements Serializable {
@@ -23,5 +28,10 @@ public class GradAlgorithmGraduationStatus implements Serializable {
2328
private String studentStatus;
2429
private UUID studentID;
2530
private String consumerEducationRequirementMet;
26-
private Date adultStartDate;
31+
@JsonFormat(pattern=DEFAULT_DATE_FORMAT)
32+
private LocalDate adultStartDate;
33+
34+
public Date getAdultStartDate() {
35+
return RuleEngineApiUtils.toDate(adultStartDate);
36+
}
2737
}

‎api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleEngineApiUtils.java

+8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.text.SimpleDateFormat;
1515
import java.time.LocalDate;
1616
import java.time.Period;
17+
import java.time.ZoneId;
1718
import java.util.*;
1819
import java.util.stream.Collectors;
1920

@@ -41,6 +42,13 @@ public static Date parseDate(String dateString, String dateFormat) throws ParseE
4142

4243
return date;
4344
}
45+
46+
public static Date toDate(LocalDate localDate) {
47+
if(localDate == null) return null;
48+
return Date.from(localDate.atStartOfDay()
49+
.atZone(ZoneId.systemDefault())
50+
.toInstant());
51+
}
4452

4553
public static Date parsingTraxDate(String sessionDate) {
4654
String actualSessionDate = sessionDate + "/01";

0 commit comments

Comments
 (0)