mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Merge remote-tracking branch 'origin/Story28_GetCorrectTimeZone' into develop
# Conflicts: # src/main/java/seng302/controllers/Controller.java
This commit is contained in:
@@ -24,6 +24,9 @@ import java.net.URL;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class Controller implements Initializable {
|
||||
@FXML
|
||||
@@ -65,7 +68,9 @@ public class Controller implements Initializable {
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
|
||||
//DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
||||
//format.setTimeZone(TimeZone.getTimeZone("GMT-8"));
|
||||
//realTime.setText(format.format(new Date()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -167,6 +167,22 @@ public class StreamParser extends Thread{
|
||||
long heartbeat = bytesToLong(packet.getPayload());
|
||||
}
|
||||
|
||||
private static String getTimeZoneString() {
|
||||
|
||||
Integer offset = xmlObject.getRegattaXML().getUtcOffset();
|
||||
StringBuilder utcOffset = new StringBuilder();
|
||||
utcOffset.append("GMT");
|
||||
if (offset > 0) {
|
||||
utcOffset.append("+");
|
||||
utcOffset.append(offset);
|
||||
} else if (offset < 0) {
|
||||
utcOffset.append("-");
|
||||
utcOffset.append(offset);
|
||||
}
|
||||
return utcOffset.toString();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the useful race status data from race status type packets. This method will also print to the
|
||||
* console the current state of the race (if it has started/finished or is about to start), along side
|
||||
@@ -182,10 +198,15 @@ public class StreamParser extends Thread{
|
||||
int raceStatus = payload[11];
|
||||
// System.out.println("raceStatus = " + raceStatus);
|
||||
long expectedStartTime = bytesToLong(Arrays.copyOfRange(payload,12,18));
|
||||
|
||||
DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
||||
format.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
if (xmlObject.getRegattaXML() != null) {
|
||||
format.setTimeZone(TimeZone.getTimeZone(getTimeZoneString()));
|
||||
currentTimeString = format.format((new Date (currentTime)).getTime());
|
||||
}
|
||||
long timeTillStart = ((new Date (expectedStartTime)).getTime() - (new Date (currentTime)).getTime())/1000;
|
||||
currentTimeString = format.format((new Date (currentTime)).getTime());
|
||||
|
||||
|
||||
if (timeTillStart > 0) {
|
||||
timeSinceStart = timeTillStart;
|
||||
//System.out.println("Time till start: " + timeTillStart + " Seconds");
|
||||
|
||||
Reference in New Issue
Block a user