#17 implementation JsonTaskDatabase.java, gradle import for jackson
This commit is contained in:
parent
e228b9019d
commit
904041afc0
|
@ -4,10 +4,12 @@ import ch.zhaw.gartenverwaltung.types.Task;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.deser.MonthDayDeserializer;
|
import com.fasterxml.jackson.datatype.jsr310.deser.MonthDayDeserializer;
|
||||||
|
import javafx.util.converter.LocalDateStringConverter;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.MonthDay;
|
import java.time.MonthDay;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -18,6 +20,18 @@ import java.util.Optional;
|
||||||
public class JsonTaskDatabase implements TaskDatabase{
|
public class JsonTaskDatabase implements TaskDatabase{
|
||||||
private final URL dataSource = getClass().getResource("taskdb.json");
|
private final URL dataSource = getClass().getResource("taskdb.json");
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Date date = new Date();
|
||||||
|
Date yesterday = new Date(-1);
|
||||||
|
Task testTask = new Task("water", "apply water", date);
|
||||||
|
JsonTaskDatabase jsonTaskDatabase = new JsonTaskDatabase();
|
||||||
|
try {
|
||||||
|
jsonTaskDatabase.saveTask(testTask);
|
||||||
|
System.out.println(jsonTaskDatabase.getTaskList(yesterday,date));
|
||||||
|
} catch (Exception e){
|
||||||
|
System.out.println("Task saving failed!");
|
||||||
|
}
|
||||||
|
}
|
||||||
private final static JavaTimeModule timeModule = new JavaTimeModule();
|
private final static JavaTimeModule timeModule = new JavaTimeModule();
|
||||||
static {
|
static {
|
||||||
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("MM-dd");
|
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("MM-dd");
|
||||||
|
|
Loading…
Reference in New Issue