Skip to content

Commit

Permalink
Modify XmlAdaptedTask to be able to support tasks with no updated tim…
Browse files Browse the repository at this point in the history
…e specified
  • Loading branch information
rachx committed Nov 4, 2016
1 parent b1f7d7b commit cbc613a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main/java/seedu/agendum/storage/XmlAdaptedTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,23 @@ public Task toModelType() throws IllegalValueException {
final boolean markedAsCompleted = Boolean.valueOf(isCompleted);

Task newTask = new Task(name);
newTask.setLastUpdatedTime(LocalDateTime.parse(this.lastUpdatedTime, formatter));

if (lastUpdatedTime != null) {
newTask.setLastUpdatedTime(LocalDateTime.parse(lastUpdatedTime, formatter));
} else {
newTask.setLastUpdatedTimeToNow();
}

if (markedAsCompleted) {
newTask.markAsCompleted();
}

if (startDateTime != null) {
newTask.setStartDateTime(Optional.ofNullable(LocalDateTime.parse(this.startDateTime, formatter)));
newTask.setStartDateTime(Optional.ofNullable(LocalDateTime.parse(startDateTime, formatter)));
}

if (endDateTime != null) {
newTask.setEndDateTime(Optional.ofNullable(LocalDateTime.parse(this.endDateTime, formatter)));
newTask.setEndDateTime(Optional.ofNullable(LocalDateTime.parse(endDateTime, formatter)));
}

return newTask;
Expand Down

0 comments on commit cbc613a

Please sign in to comment.