Skip to content

Commit

Permalink
Fixed time format used for generating avl reports
Browse files Browse the repository at this point in the history
  • Loading branch information
vesavlad committed Feb 19, 2024
1 parent 13bdd51 commit a5bc6f5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions core/src/main/java/org/transitclock/utils/Time.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/* (C)2023 */
package org.transitclock.utils;

import lombok.extern.slf4j.Slf4j;
import org.transitclock.domain.structs.Agency;
import org.transitclock.gtfs.DbConfig;

import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.ParseException;
Expand All @@ -9,8 +13,6 @@
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;
import org.transitclock.domain.structs.Agency;
import org.transitclock.gtfs.DbConfig;

/**
* Contains convenience methods for dealing with time issues.
Expand All @@ -21,6 +23,7 @@
*
* @author SkiBu Smith
*/
@Slf4j
public class Time {
// Some handy constants for dealing with time.
// MS_PER_SEC and MS_PER_MIN are declared as integers since they after
Expand Down Expand Up @@ -59,7 +62,7 @@ public class Time {

// These two are for reading in dates in various formats
private static final DateFormat defaultDateFormat = SimpleDateFormat.getDateInstance(DateFormat.SHORT);
private static final DateFormat dateFormatDashesShortYear = new SimpleDateFormat("dd-MM-yy");
private static final DateFormat dateFormatDashesShortYear = new SimpleDateFormat("MM-dd-yy");

private static final DateFormat readableDateFormat = new SimpleDateFormat("dd-MM-yyyy");

Expand Down Expand Up @@ -402,7 +405,7 @@ public static Date parseDate(String dateStr) throws ParseException {
try {
return defaultDateFormat.parse(dateStr);
} catch (ParseException e) {
e.printStackTrace();
logger.warn("Cannot parse {} using defaultDateFormat.", dateStr, e);
}
// Try using "-" instead of "/" as separator. Having the date formatter
// specify only two digits for the year means it also works when 4
Expand Down

0 comments on commit a5bc6f5

Please sign in to comment.