Skip to content
Snippets Groups Projects

Issue #18, #19 resolved

1 file
+ 8
3
Compare changes
  • Side-by-side
  • Inline
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import jakarta.ws.rs.BadRequestException;
import jakarta.ws.rs.NotFoundException;
import java.time.format.DateTimeFormatter;
import nl.utwente.mod4.pokemon.Utils;
import nl.utwente.mod4.pokemon.model.Trainer;
@@ -19,6 +20,7 @@ public enum TrainerDao {
private static final String ORIGINAL_TRAINERS = Utils.getAbsolutePathToResources() + "/default-trainers-dataset.json";
private static final String TRAINERS = Utils.getAbsolutePathToResources() + "/trainers.json";
private final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
private HashMap<String, Trainer> trainers = new HashMap<>();
@@ -81,8 +83,10 @@ public enum TrainerDao {
String nextId = "" + (getMaxId() + 1);
newTrainer.id = nextId;
newTrainer.created = Instant.now().toString();
newTrainer.lastUpDate = Instant.now().toString();
newTrainer.created = dateFormatter.format(Instant.now());
newTrainer.lastUpDate = dateFormatter.format(Instant.now());
// newTrainer.created = Instant.now().toString();
// newTrainer.lastUpDate = Instant.now().toString();
trainers.put(nextId,newTrainer);
return newTrainer;
@@ -94,7 +98,8 @@ public enum TrainerDao {
if(trainers.get(updated.id) == null)
throw new NotFoundException("Trainer id '" + updated.id + "' not found.");
updated.lastUpDate = Instant.now().toString();
// updated.lastUpDate = Instant.now().toString();
updated.lastUpDate = dateFormatter.format(Instant.now());
trainers.put(updated.id,updated);
return updated;
Loading