-
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 cb53e96
Showing
5 changed files
with
64 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
18 changes: 18 additions & 0 deletions
18
...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,18 @@ | ||
package edu.harvard.hms.dbmi.avillach.hpds.processing.timeseries; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.util.TimeZone; | ||
|
||
@Service | ||
public class TimeSeriesConversionService { | ||
|
||
public String toISOString(Long unixTimeStamp, TimeZone timeZone) { | ||
Date date = new Date(unixTimeStamp); | ||
SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'"); | ||
isoFormat.setTimeZone(timeZone); | ||
return isoFormat.format(date); | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
...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,22 @@ | ||
package edu.harvard.hms.dbmi.avillach.hpds.processing.timeseries; | ||
|
||
import org.junit.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
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, TimeZone.getTimeZone("UTC")); | ||
String expected = "1970-01-01T00:00:00.0Z"; | ||
|
||
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