-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Roman/file split feature #161
base: josh/refactor
Are you sure you want to change the base?
Changes from all commits
b2ceb7e
89dc550
52667d4
40d92e9
8a415d7
b810e55
0a26a22
d852871
12b6120
2fd77bd
279a1d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,7 +113,6 @@ public static void main(String[] arguments) throws SQLException { | |
* non-existant | ||
* upload. This can cause the upload process to crash. | ||
* | ||
* @param connection is the connection to the database | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ProcessUpload from josh/refactor currently throw errors for me, needs revisiting. |
||
*/ | ||
public static void removeNoUploadFlights() { | ||
try (Connection connection = Database.getConnection()) { | ||
|
@@ -134,6 +133,9 @@ public static void removeNoUploadFlights() { | |
} | ||
|
||
public static void operateAsDaemon() throws SQLException { | ||
|
||
LOG.info("Operate as daemon log. "); | ||
|
||
while (true) { | ||
Instant start = Instant.now(); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,11 +115,38 @@ public static String toUTC(String date, String time, String offset) { | |
|
||
} | ||
|
||
/** | ||
* List of DateTime formats supported. | ||
*/ | ||
private static final List<DateTimeFormatter> dateTimeFormatters = Arrays.asList( | ||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"), | ||
DateTimeFormatter.ofPattern("M/d/yyyy HH:mm:ss") | ||
|
||
); | ||
|
||
/** | ||
* Helper method to parse the date and time using the declared formatters | ||
* @param dateTimeString | ||
* @return | ||
*/ | ||
public static LocalDateTime parseDateTime(String dateTimeString) { | ||
String normalizedDateTime = dateTimeString.replaceAll("\\s+", " "); // Replaces multiple spaces with a single space | ||
for (DateTimeFormatter formatter : dateTimeFormatters) { | ||
try { | ||
return LocalDateTime.parse(normalizedDateTime, formatter); | ||
} catch (Exception e) { | ||
// Continue trying other formats | ||
} | ||
} | ||
// If none of the formats work, throw an exception or handle it appropriately | ||
throw new IllegalArgumentException("Date format not supported: " + normalizedDateTime); | ||
} | ||
|
||
public static OffsetDateTime convertToOffset(String originalDate, String originalTime, String originalOffset, String newOffset) { | ||
//System.out.println("original: \t" + originalTime + " " + originalOffset + " new offset: "+ newOffset); | ||
|
||
// create a LocalDateTime using the date time passed as parameter | ||
LocalDateTime ldt = LocalDateTime.parse(originalDate + " " + originalTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); | ||
LocalDateTime ldt = parseDateTime(originalDate + " " + originalTime); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uses parseDateTime method (utilizes multiple parse formats) instead of doing parsing itself. |
||
|
||
//fix bad offset values | ||
originalOffset = updateBadOffset(ldt, originalOffset); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should match the Database.java from josh/refactor