src/main/java/uk/gov/hmcts/reform/sendletter/services/StaleLetterService.java
private ZonedDateTime calculateCutOffCreationDate() {
        ZonedDateTime now =
            ZonedDateTime
                .now(clock)
                .withZoneSameInstant(SERVICE_TIME_ZONE_ID);

        // If on a given day a letter was created within FTP downtime window or later,
        // it should be treated like it was created the next day.
        LocalTime ftpDowntimeAdjustedTime =
            now.toLocalTime().isBefore(ftpDowntimeStart)
                ? now.toLocalTime()
                : ftpDowntimeStart;

        ZonedDateTime todayWithFtpDowntimeAdjustedTime =
            now
                .truncatedTo(DAYS)
                .plusNanos(ftpDowntimeAdjustedTime.toNanoOfDay());

        return dateCalculator.subtractBusinessDays(
            todayWithFtpDowntimeAdjustedTime,
            minStaleLetterAgeInBusinessDays
        );
    }
/**
     * Calculates the cut-off creation date for stale letters.
     *
     * @return Cut-off creation date for stale letters. Only letters older than that
     *         can be considered stale.
     */
Calculates the cut-off creation date for stale letters.
@return Cut-off creation date for stale letters. Only letters older than that
can be considered stale.
Calculates the cut - off creation date for stale letters . @return Cut - off creation date for stale letters . Only letters older than that can be considered stale .
private ZonedDateTime calculateCutOffCreationDate() {
        ZonedDateTime now =
            ZonedDateTime
                .now(clock)
                .withZoneSameInstant(SERVICE_TIME_ZONE_ID);
        LocalTime ftpDowntimeAdjustedTime =
            now.toLocalTime().isBefore(ftpDowntimeStart)
                ? now.toLocalTime()
                : ftpDowntimeStart;
        ZonedDateTime todayWithFtpDowntimeAdjustedTime =
            now
                .truncatedTo(DAYS)
                .plusNanos(ftpDowntimeAdjustedTime.toNanoOfDay());
        return dateCalculator.subtractBusinessDays(
            todayWithFtpDowntimeAdjustedTime,
            minStaleLetterAgeInBusinessDays
        );
    }
private ZonedDateTime calculateCutOffCreationDate ( ) { ZonedDateTime now = ZonedDateTime . now ( clock ) . withZoneSameInstant ( SERVICE_TIME_ZONE_ID ) ; LocalTime ftpDowntimeAdjustedTime = now . toLocalTime ( ) . isBefore ( ftpDowntimeStart ) ? now . toLocalTime ( ) : ftpDowntimeStart ; ZonedDateTime todayWithFtpDowntimeAdjustedTime = now . truncatedTo ( DAYS ) . plusNanos ( ftpDowntimeAdjustedTime . toNanoOfDay ( ) ) ; return dateCalculator . subtractBusinessDays ( todayWithFtpDowntimeAdjustedTime , minStaleLetterAgeInBusinessDays ) ; }
Calculates the cut-off creation date for stale letters.
Calculates the cut - off creation date for stale letters .
// If on a given day a letter was created within FTP downtime window or later, // it should be treated like it was created the next day.