diff --git a/src/main/java/uk/gov/hmcts/opal/controllers/DraftAccountController.java b/src/main/java/uk/gov/hmcts/opal/controllers/DraftAccountController.java index 57a830a35..2ce3fbf3e 100644 --- a/src/main/java/uk/gov/hmcts/opal/controllers/DraftAccountController.java +++ b/src/main/java/uk/gov/hmcts/opal/controllers/DraftAccountController.java @@ -40,7 +40,7 @@ import java.util.List; import java.util.Optional; -import static uk.gov.hmcts.opal.util.DateTimeUtils.toOffsetDateTime; +import static uk.gov.hmcts.opal.util.DateTimeUtils.toUtcDateTime; import static uk.gov.hmcts.opal.util.HttpUtil.buildCreatedResponse; import static uk.gov.hmcts.opal.util.HttpUtil.buildResponse; @@ -247,16 +247,16 @@ DraftAccountResponseDto toGetResponseDto(DraftAccountEntity entity) { .draftAccountId(entity.getDraftAccountId()) .businessUnitId(Optional.ofNullable(entity.getBusinessUnit()) .map(BusinessUnitEntity::getBusinessUnitId).orElse(null)) - .createdDate(toOffsetDateTime(entity.getCreatedDate())) + .createdDate(toUtcDateTime(entity.getCreatedDate())) .submittedBy(entity.getSubmittedBy()) .submittedByName(entity.getSubmittedByName()) - .validatedDate(toOffsetDateTime(entity.getValidatedDate())) + .validatedDate(toUtcDateTime(entity.getValidatedDate())) .validatedBy(entity.getValidatedBy()) .account(entity.getAccount()) .accountSnapshot(entity.getAccountSnapshot()) .accountType(entity.getAccountType()) .accountStatus(entity.getAccountStatus()) - .accountStatusDate(toOffsetDateTime(entity.getAccountStatusDate())) + .accountStatusDate(toUtcDateTime(entity.getAccountStatusDate())) .statusMessage(entity.getStatusMessage()) .timelineData(entity.getTimelineData()) .accountNumber(entity.getAccountNumber()) @@ -268,9 +268,9 @@ DraftAccountSummaryDto toSummaryDto(DraftAccountEntity entity) { return DraftAccountSummaryDto.builder() .draftAccountId(entity.getDraftAccountId()) .businessUnitId(entity.getBusinessUnit().getBusinessUnitId()) - .createdDate(toOffsetDateTime(entity.getCreatedDate())) + .createdDate(toUtcDateTime(entity.getCreatedDate())) .submittedBy(entity.getSubmittedBy()) - .validatedDate(toOffsetDateTime(entity.getValidatedDate())) + .validatedDate(toUtcDateTime(entity.getValidatedDate())) .validatedBy(entity.getValidatedBy()) .accountSnapshot(entity.getAccountSnapshot()) .accountType(entity.getAccountType()) diff --git a/src/main/java/uk/gov/hmcts/opal/service/opal/DraftAccountService.java b/src/main/java/uk/gov/hmcts/opal/service/opal/DraftAccountService.java index 5092977a9..bff984bb2 100644 --- a/src/main/java/uk/gov/hmcts/opal/service/opal/DraftAccountService.java +++ b/src/main/java/uk/gov/hmcts/opal/service/opal/DraftAccountService.java @@ -34,6 +34,7 @@ import java.util.List; import java.util.Optional; +import static uk.gov.hmcts.opal.util.DateTimeUtils.toUtcDateTime; import static uk.gov.hmcts.opal.util.JsonPathUtil.createDocContext; @Service @@ -221,7 +222,7 @@ private DraftAccountSnapshots.Snapshot buildSnapshot(String document, LocalDate return DraftAccountSnapshots.Snapshot.builder() .defendantName(defendantName) .dateOfBirth(dob) - .createdDate(created.atOffset(ZoneOffset.UTC)) + .createdDate(toUtcDateTime(created)) .accountType(accType) .submittedBy(submittedBy) .submittedByName(submittedByName) diff --git a/src/main/java/uk/gov/hmcts/opal/util/DateTimeUtils.java b/src/main/java/uk/gov/hmcts/opal/util/DateTimeUtils.java index 1d205fc17..b8de64210 100644 --- a/src/main/java/uk/gov/hmcts/opal/util/DateTimeUtils.java +++ b/src/main/java/uk/gov/hmcts/opal/util/DateTimeUtils.java @@ -7,7 +7,7 @@ public class DateTimeUtils { - public static OffsetDateTime toOffsetDateTime(LocalDateTime localDateTime) { + public static OffsetDateTime toUtcDateTime(LocalDateTime localDateTime) { return Optional.ofNullable(localDateTime) .map(ldt -> ldt.atOffset(ZoneOffset.UTC)) .orElse(null); diff --git a/src/test/java/uk/gov/hmcts/opal/controllers/DraftAccountControllerTest.java b/src/test/java/uk/gov/hmcts/opal/controllers/DraftAccountControllerTest.java index 2712039d8..e0d2947a1 100644 --- a/src/test/java/uk/gov/hmcts/opal/controllers/DraftAccountControllerTest.java +++ b/src/test/java/uk/gov/hmcts/opal/controllers/DraftAccountControllerTest.java @@ -30,7 +30,7 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static uk.gov.hmcts.opal.util.DateTimeUtils.toOffsetDateTime; +import static uk.gov.hmcts.opal.util.DateTimeUtils.toUtcDateTime; @ExtendWith(MockitoExtension.class) class DraftAccountControllerTest { @@ -170,9 +170,9 @@ DraftAccountResponseDto toGetDto(DraftAccountEntity entity) { return DraftAccountResponseDto.builder() .draftAccountId(entity.getDraftAccountId()) .businessUnitId(entity.getBusinessUnit().getBusinessUnitId()) - .createdDate(toOffsetDateTime(entity.getCreatedDate())) + .createdDate(toUtcDateTime(entity.getCreatedDate())) .submittedBy(entity.getSubmittedBy()) - .validatedDate(toOffsetDateTime(entity.getValidatedDate())) + .validatedDate(toUtcDateTime(entity.getValidatedDate())) .validatedBy(entity.getValidatedBy()) .account(entity.getAccount()) .accountSnapshot(entity.getAccountSnapshot()) @@ -188,9 +188,9 @@ DraftAccountSummaryDto toSummaryDto(DraftAccountEntity entity) { return DraftAccountSummaryDto.builder() .draftAccountId(entity.getDraftAccountId()) .businessUnitId(entity.getBusinessUnit().getBusinessUnitId()) - .createdDate(toOffsetDateTime(entity.getCreatedDate())) + .createdDate(toUtcDateTime(entity.getCreatedDate())) .submittedBy(entity.getSubmittedBy()) - .validatedDate(toOffsetDateTime(entity.getValidatedDate())) + .validatedDate(toUtcDateTime(entity.getValidatedDate())) .validatedBy(entity.getValidatedBy()) .accountSnapshot(entity.getAccountSnapshot()) .accountType(entity.getAccountType())