diff --git a/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java b/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java index 966769b4..e47cee38 100644 --- a/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java +++ b/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java @@ -188,7 +188,7 @@ public String getValueAsString() { try { return jsonParser.getValueAsString(); } catch (IOException e) { - throw new RuntimeException("Error getting the current token as String", e); + throw new SerializationException("Error getting the current token as String", e); } } @@ -197,7 +197,7 @@ public Integer getValueAsInt() { try { return Integer.parseInt(taggedTokenValue); } catch (NumberFormatException e) { - throw new RuntimeException("Error getting the current token as Integer", e); + throw new SerializationException("Error getting the current token as Integer", e); } } @@ -205,7 +205,7 @@ public Boolean getValueAsBoolean() { try { return jsonParser.getValueAsBoolean(); } catch (IOException e) { - throw new RuntimeException("Error getting the current token as Boolean", e); + throw new SerializationException("Error getting the current token as Boolean", e); } } @@ -214,7 +214,7 @@ public LocalDate getValueAsLocalDate() { try { return LocalDate.parse(taggedTokenValue); } catch (NumberFormatException e) { - throw new RuntimeException("Error getting the current token as LocalDate", e); + throw new SerializationException("Error getting the current token as LocalDate", e); } } @@ -223,7 +223,7 @@ public Instant getValueAsTime() { try { return Instant.parse(taggedTokenValue); } catch (NumberFormatException e) { - throw new RuntimeException("Error getting the current token as LocalDateTime", e); + throw new SerializationException("Error getting the current token as LocalDateTime", e); } } } \ No newline at end of file diff --git a/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java b/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java index 363d511c..2863daa2 100644 --- a/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java +++ b/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java @@ -125,6 +125,22 @@ public void testeGetValueAsTime() throws IOException { assertThrows(RuntimeException.class, invalidReader::getValueAsLocalDate); } + @Test + public void testeGetValueAsTimeNonUTC() throws IOException { + String s = "{\"@time\":\"2023-12-03T05:52:10.000001-09:00\"}"; + InputStream inputStream = new ByteArrayInputStream(s.getBytes()); + FaunaParser reader = new FaunaParser(inputStream); + + Instant instant = Instant.parse("2023-12-03T05:52:10.000001-09:00"); + + List> expectedTokens = List.of( + Map.entry(FaunaTokenType.TIME, instant) + ); + + assertReader(reader, expectedTokens); + + } + private static void assertReader(FaunaParser reader, List> tokens) throws IOException { for (Map.Entry entry : tokens) {