Skip to content

Commit

Permalink
Method rename to show explicit conversion to UTC date time.
Browse files Browse the repository at this point in the history
  • Loading branch information
RustyHMCTS committed Jan 13, 2025
1 parent 9435559 commit ba8d4a5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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())
Expand All @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/uk/gov/hmcts/opal/util/DateTimeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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())
Expand All @@ -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())
Expand Down

0 comments on commit ba8d4a5

Please sign in to comment.