Skip to content

Commit

Permalink
remove TimeFixer.java, set datetimeformat timezone to UTC
Browse files Browse the repository at this point in the history
  • Loading branch information
xspanger3770 committed Aug 19, 2023
1 parent 8214f32 commit e89f0e8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
21 changes: 13 additions & 8 deletions src/main/java/globalquake/database/SeedlinkCommunicator.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package globalquake.database;

import edu.sc.seis.seisFile.seedlink.SeedlinkReader;
import globalquake.utils.TimeFixer;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
Expand All @@ -13,11 +12,17 @@
import java.io.StringReader;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;

public class SeedlinkCommunicator {

private static final SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private static final SimpleDateFormat format3 = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSSS");
private static final SimpleDateFormat FORMAT_UTC_SHORT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private static final SimpleDateFormat FORMAT_UTC_LONG = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSSS");

static{
FORMAT_UTC_SHORT.setTimeZone(TimeZone.getTimeZone("UTC"));
FORMAT_UTC_LONG.setTimeZone(TimeZone.getTimeZone("UTC"));
}

public static void runAvailabilityCheck(SeedlinkNetwork seedlinkNetwork, StationDatabase stationDatabase) throws Exception {
seedlinkNetwork.getStatus().setString("Connecting...");
Expand Down Expand Up @@ -57,11 +62,11 @@ private static void parseAvailability(String infoString, StationDatabase station
String channelName = channel.getAttributes().getNamedItem("seedname").getTextContent();
String endDate = channel.getAttributes().getNamedItem("end_time").getTextContent();
Calendar end = Calendar.getInstance();
end.setTime(endDate.contains("-") ? format2.parse(endDate) : format3.parse(endDate));
long delay = System.currentTimeMillis() - end.getTimeInMillis() - TimeFixer.offset();
if (delay > 1000 * 60 * 15) {
continue;
}
end.setTime(endDate.contains("-") ? FORMAT_UTC_SHORT.parse(endDate) : FORMAT_UTC_LONG.parse(endDate));

long delay = System.currentTimeMillis() - end.getTimeInMillis();
System.out.println(delay);

addAvailableChannel(networkCode, stationCode, channelName, locationCode, delay, seedlinkNetwork, stationDatabase);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public void runAvailabilityCheck(List<SeedlinkNetwork> toBeUpdated, Runnable onF
SeedlinkCommunicator.runAvailabilityCheck(seedlinkNetwork, stationDatabase);
break;
} catch (Exception e) {
e.printStackTrace();
seedlinkNetwork.getStatus().setString("Error!");
seedlinkNetwork.getStatus().setValue(0);
} finally {
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/globalquake/utils/TimeFixer.java

This file was deleted.

0 comments on commit e89f0e8

Please sign in to comment.