-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ALS-5755] Switch time series processor to ISO timestamps
- Make service that does this - Isolate time series logic a bit more - Tests
- Loading branch information
Luke Sikina
committed
Jan 23, 2024
1 parent
c6d8296
commit dc03f3e
Showing
5 changed files
with
62 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...edu/harvard/hms/dbmi/avillach/hpds/processing/timeseries/TimeSeriesConversionService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package edu.harvard.hms.dbmi.avillach.hpds.processing.timeseries; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.time.format.DateTimeFormatter; | ||
import java.util.Date; | ||
import java.util.TimeZone; | ||
|
||
@Service | ||
public class TimeSeriesConversionService { | ||
|
||
public String toISOString(Long unixTimeStamp) { | ||
Date date = new Date(unixTimeStamp); | ||
return DateTimeFormatter.ISO_INSTANT.format(date.toInstant()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...harvard/hms/dbmi/avillach/hpds/processing/timeseries/TimeSeriesConversionServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package edu.harvard.hms.dbmi.avillach.hpds.processing.timeseries; | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.TimeZone; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
|
||
public class TimeSeriesConversionServiceTest { | ||
|
||
TimeSeriesConversionService subject = new TimeSeriesConversionService(); | ||
|
||
@Test | ||
public void shouldConvertToIsoString() { | ||
String actual = subject.toISOString(0L); | ||
String expected = "1970-01-01T00:00:00Z"; | ||
|
||
assertEquals(expected, actual); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters