Improve updater

This commit is contained in:
2020-10-04 11:53:30 +02:00
parent babfe66872
commit e57f79c18b
15 changed files with 14771 additions and 22 deletions
@@ -1,2 +1,65 @@
<<<<<<< HEAD
package de.jeyp91.tippliga;
import com.google.common.io.Resources;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Date;
public class TLWMatchesManagerBase {
protected int season;
protected int league;
protected int numberOfMatchdays;
protected int matchesPerMatchday;
protected int ko;
protected JSONArray matchdayConfig;
protected void initConfigParamsFromFile(String configFileName) {
URL url = Resources.getResource(season + File.separator + configFileName);
String jsonConfig = null;
try {
JSONParser jsonParser = new JSONParser();
jsonConfig = Resources.toString(url, StandardCharsets.UTF_8);
//Read JSON file
JSONObject config = (JSONObject) jsonParser.parse(jsonConfig);
this.numberOfMatchdays = ((Long) config.get("numberOfMatchdays")).intValue();
this.matchdayConfig = (JSONArray) config.get("matchdayConfig");
this.ko = ((Long) config.get("ko")).intValue();
} catch (IOException | ParseException e) {
e.printStackTrace();
}
}
protected int getDaysDifference(Date date1, Date date2) {
long startTime = date1.getTime();
long endTime = date2.getTime();
long diffTime = endTime - startTime;
long diffDays = diffTime / (1000 * 60 * 60 * 24);
return (int) diffDays;
}
protected Date getDateObject(String matchdatetime) {
Date matchDateTime = null;
try {
matchDateTime = new SimpleDateFormat("yyyy-MM-dd").parse(matchdatetime.substring(0, 10));
} catch (java.text.ParseException e) {
e.printStackTrace();
}
return matchDateTime;
}
=======
package de.jeyp91.tippliga;public class TLWMatchesManagerBase {
>>>>>>> origin/master
}