Skip to content

Commit

Permalink
fix date in UTC
Browse files Browse the repository at this point in the history
  • Loading branch information
noemil12 committed Nov 29, 2023
1 parent 2a14a99 commit a166c5b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Mono;

import java.time.Instant;
import java.time.LocalDate;

@Repository
public interface SignalRepository extends ReactiveCrudRepository<Signal, Long> {

@Query("delete from SIGNAL where tmst_Insert < :date")
Mono<Void> deleteByDate(LocalDate date );
Mono<Void> deleteByDate(Instant date );

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.Instant;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;

Expand All @@ -23,10 +24,10 @@ public class SignalServiceImpl implements SignalService {
private AppConfig appConfig;

public void cleanSignal() {
LocalDate pastDate = LocalDate.now().minus(Long.parseLong(appConfig.getDelayDays()), ChronoUnit.DAYS);
Instant pastDate = Instant.now().minus(Long.parseLong(appConfig.getDelayDays()), ChronoUnit.DAYS);
signalRepository.deleteByDate(pastDate)
.doOnSuccess(x -> log.info("clean complete with success"))
.doOnError(ex -> log.error("Find an error {}",ex))
.doOnError(ex -> log.error("Error on signal cleanup {}",ex))
.subscribe();
}

Expand Down

0 comments on commit a166c5b

Please sign in to comment.