Skip to content

Commit

Permalink
Merge pull request #62 from DeveloperDeborah/master
Browse files Browse the repository at this point in the history
Fix grabbing time instants from sql
  • Loading branch information
mortenn authored Dec 21, 2023
2 parents a0655f1 + 07bfe13 commit 973735f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/no/runsafe/framework/internal/database/DataConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.UUID;

@SuppressWarnings("ChainOfInstanceofChecks")
Expand Down Expand Up @@ -146,10 +149,14 @@ static Instant Instant(Object value)
if (value == null)
return null;

// Example of date format needed: 2024-12-19T15:35:25Z
// Example of date format needed: 2024-12-19T15:35:25
// Example of date format given: 2024-12-19 15:35:25

return Instant.parse(value.toString().replace(" ", "T") + "Z");
// Input value was recorded in the server's time zone, convert it before turning it into an Instant
return ZonedDateTime.of(
LocalDateTime.parse(value.toString().replace(" ", "T")),
ZoneId.systemDefault()
).toInstant();
}

@SuppressWarnings("MethodWithTooManyParameters")
Expand Down

0 comments on commit 973735f

Please sign in to comment.