Skip to content

Commit

Permalink
fix: fixed tostring
Browse files Browse the repository at this point in the history
  • Loading branch information
Toto-hitori committed Apr 9, 2024
1 parent c687b15 commit 28160d1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions api/src/main/java/lab/en2b/quizapi/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Game {

private Long correctlyAnsweredQuestions = 0L;
private String language;
private String roundStartTime;
private Long roundStartTime = 0L;
@NonNull
private Integer roundDuration;
private boolean currentQuestionAnswered;
Expand Down Expand Up @@ -64,7 +64,7 @@ public void newRound(Question question){
setCurrentQuestionAnswered(false);
getQuestions().add(question);
increaseRound();
setRoundStartTime(Instant.now().toString());
setRoundStartTime(Instant.now().toEpochMilli());
}

private void increaseRound(){
Expand Down Expand Up @@ -92,7 +92,7 @@ private boolean currentRoundIsOver(){
}

private boolean roundTimeHasExpired(){
return getRoundStartTime()!= null && Instant.now().isAfter(Instant.parse(getRoundStartTime()).plusSeconds(getRoundDuration()));
return getRoundStartTime()!= null && Instant.now().isAfter(Instant.ofEpochMilli(getRoundStartTime()).plusSeconds(getRoundDuration()));
}

public boolean answerQuestion(Long answerId){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.time.Instant;
import java.util.function.Function;

@Service
Expand All @@ -21,7 +22,7 @@ public GameResponseDto apply(Game game) {
.correctlyAnsweredQuestions(game.getCorrectlyAnsweredQuestions())
.actualRound(game.getActualRound())
.roundDuration(game.getRoundDuration())
.roundStartTime(game.getRoundStartTime())
.roundStartTime(Instant.ofEpochMilli(game.getRoundStartTime()).toString())
.isGameOver(game.isGameOver())
.build();
}
Expand Down

0 comments on commit 28160d1

Please sign in to comment.