Fixed date time parsing problem
#story[778]
This commit is contained in:
@@ -17,7 +17,9 @@ import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import java.io.StringWriter;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
|
||||
/**
|
||||
* Created by esa46 on 21/04/17.
|
||||
@@ -27,11 +29,11 @@ public class RaceData {
|
||||
private RaceDataSource dataSource;
|
||||
private Document doc;
|
||||
private Element rootElement;
|
||||
private OffsetDateTime creationTimeDate;
|
||||
private ZonedDateTime creationTimeDate;
|
||||
|
||||
public RaceData(RaceDataSource dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
creationTimeDate = OffsetDateTime.now();
|
||||
creationTimeDate = ZonedDateTime.now();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,7 +111,9 @@ public class RaceData {
|
||||
*/
|
||||
private void appendCreationTimeDate() {
|
||||
Element creationTimeElement = doc.createElement("CreationTimeDate");
|
||||
creationTimeElement.appendChild(doc.createTextNode(creationTimeDate.toString()));
|
||||
|
||||
|
||||
creationTimeElement.appendChild(doc.createTextNode(toTruncatedString(creationTimeDate)));
|
||||
rootElement.appendChild(creationTimeElement);
|
||||
}
|
||||
|
||||
@@ -118,7 +122,7 @@ public class RaceData {
|
||||
*/
|
||||
private void appendRaceStartTime() {
|
||||
Element startTimeElement = doc.createElement("RaceStartTime");
|
||||
startTimeElement.setAttribute("Time", (creationTimeDate.plusMinutes(3)).toString());
|
||||
startTimeElement.setAttribute("Time", (toTruncatedString(creationTimeDate.plusMinutes(0))));
|
||||
startTimeElement.setAttribute("Postpone", "false");
|
||||
rootElement.appendChild(startTimeElement);
|
||||
}
|
||||
@@ -179,7 +183,6 @@ public class RaceData {
|
||||
*/
|
||||
private Element createCompoundMarker(Marker marker, int i) {
|
||||
Element compoundMarkElement = doc.createElement("CompoundMark");
|
||||
System.out.println("CompoundMark, " + i);
|
||||
compoundMarkElement.setAttribute("CompoundMarkID", i + "");
|
||||
compoundMarkElement.setAttribute("Name", marker.getName());
|
||||
|
||||
@@ -227,5 +230,15 @@ public class RaceData {
|
||||
rootElement.appendChild(courseLimitElement);
|
||||
}
|
||||
|
||||
private String toTruncatedString(ZonedDateTime time) {
|
||||
|
||||
DateTimeFormatter dateFormat = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
||||
dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ");
|
||||
String text = dateFormat.format(time);
|
||||
System.out.println(text);
|
||||
return text;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,7 +44,8 @@ public class MockOutput implements Runnable
|
||||
|
||||
public MockOutput() throws IOException {
|
||||
lastHeartbeatTime = System.currentTimeMillis();
|
||||
serverSocket = new ServerSocket(4943);
|
||||
serverSocket = new ServerSocket(4942);
|
||||
|
||||
}
|
||||
/**
|
||||
* calculates the time since last heartbeat
|
||||
@@ -132,6 +133,7 @@ public class MockOutput implements Runnable
|
||||
try {
|
||||
while (true){
|
||||
mockSocket = serverSocket.accept();
|
||||
|
||||
outToVisualiser = new DataOutputStream(mockSocket.getOutputStream());
|
||||
|
||||
/*******************************Test********************************/
|
||||
|
||||
@@ -43,7 +43,7 @@ public class Event {
|
||||
System.out.println("Sending Boat");
|
||||
sendBoatData();
|
||||
|
||||
Race newRace = new Race(raceDataSource, 15, mockOutput);
|
||||
Race newRace = new Race(raceDataSource, 3, mockOutput);
|
||||
new Thread((newRace)).start();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user