I am mapping JSON data to object model in SpringBoot, looping through it and displaying it in the console.
What I am trying to do next is display JSON data FOR EACH HOUR OF THE DAY.
I googled trough what's online like this existing question but unfortunately I was not able to apply it.
Run Java code once every hour - Stackoverflow
Any suggestion would be appreciated.
I started with something like this in my model class.
public class CarResponse {
List<Car> car = new ArrayList<Car>();
public List<Car> getCar() {
return car;
}
public void setCar(List<Car> car) {
this.car = car;
}
@Override
public String toString() {
final DateFormat df = DateFormat.getDateTimeInstance();
final Calendar c = Calendar.getInstance();
c.clear();
for (c.add(Calendar.HOUR_OF_DAY, 1)) {
System.out.println(df.format(c.getTime()));
String str = "=================================\r\n";
for (Car ld : car) {
str += "\t" + "Shop: " + ld.getShop() + "\r\n";
str += "\t" + "Date: " + ld.getDate() + "\r\n";
str += "\t" + "Values: " + ld.getValues() + "\r\n";
}
return str;
}
}
}
With code above I didn't get what I wanted. Well to explain better I don't have an error, but I would like my data to be displayed in the console like this:
2021-02-26T00:00+01:00[Europe/Vienna]
=================================
Market: Audi
Date: 12321599600000
Values: []
=================================
2021-02-26T00:00+02:00[Europe/Vienna]
Market: Audi
Date: 12321599600000
Values: []
Right now I get the output like this:
2021-02-26T00:00+01:00[Europe/Vienna]
2021-02-26T00:00+01:00[Europe/Vienna]
=================================
Market: Audi
Date: 12321599600000
Values: []
Market: Audi
Date: 12321599600000
Values: []