0

So I'm using Jackson to read JSON data. I then am creating a Java object. Then from that Java object I'm reading it and inserting it into a Cassandra table. I ran into issues. I am receiving the dates as such...

"demandDepositAccountOpenDate":"9999-01-01T05:00:00.000+0000"

That's the result of a JSONNode.get function

I need to insert that date into the Cassandra table as 9999-01-01 (this would be a yyyy-MM-dd format)

I don't know what type of variable to make my date field in the Java object. Date? LocalDate? I'm having difficulties. I'm trying DateTimeFormater. SimpleDateFormat. Nothing is working. I tried making the date fields in my java object as Strings but that won't work. Just looking for a clean simple solution.

Ole V.V.
  • 81,772
  • 15
  • 137
  • 161
  • 1
    Don't know if this helps, but the format yyyy-MM-dd is the ISO 8601 of a LocalDate. What you have above looks like a LocalDateTime or ZonedDateTime. https://docs.oracle.com/javase/8/docs/api/java/time/LocalDate.html (its not clear to me if your issue is the Database of the Java Object) – Christian Fries Mar 10 '20 at 21:35
  • 1
    It looks like some format of an [`OffsetDateTime`](https://docs.oracle.com/javase/8/docs/api/java/time/OffsetDateTime.html) to me. – MC Emperor Mar 10 '20 at 23:25
  • [jackson-modules-java8](https://github.com/FasterXML/jackson-modules-java8) may require a colon in the offset, `+00:00` rather than `+0000`, I don’t know (and haven’t tried). If working in Java just use `OffsetDateTime.parse("9999-01-01T05:00:00.000+0000", DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH.mm:ss.SSSxx")).format(DateTimeFormatter.ISO_LOCAL_DATE)`. – Ole V.V. Mar 11 '20 at 06:10
  • Related: [Cannot parse String in ISO 8601 format, lacking colon in offset, to Java 8 Date](https://stackoverflow.com/questions/43360852/cannot-parse-string-in-iso-8601-format-lacking-colon-in-offset-to-java-8-date) and also [Convert date into AEST using java](https://stackoverflow.com/questions/48412345/convert-date-into-aest-using-java) and more. – Ole V.V. Mar 11 '20 at 06:14

0 Answers0