Re: Error in conversion of seconds since epoch to a date-time

2024-06-20 Thread James McMahon
After adding extensive logging I identified the problem: the combined regex pattern was not matching the entirety of values that are unix seconds since the epoch. I fixed that problem in the Groovy script, and it ran as expected. Thank you both for your comments, Paul and Christopher. On Thu, Jun

Re: Error in conversion of seconds since epoch to a date-time

2024-06-20 Thread Paul King
This would be my expectation: import java.time.Instant import java.time.ZoneId import groovy.json.JsonBuilder def lastModifiedView = '1652135219'.toLong() def zoneId = ZoneId.of('America/Los_Angeles') def date = Instant.ofEpochSecond(lastModifiedView).atZone(zoneId).toLocalDate() def result = [la

Re: Error in conversion of seconds since epoch to a date-time

2024-06-20 Thread Christopher Smith
The thing that you're producing is the naive serialization of an Instant. Jackson uses the Java 8 Time module to handle this; I'm not sure how to go about it using JsonBuilder. On Thu, Jun 20, 2024 at 4:25 PM James McMahon wrote: > Hello. I have a json key named viewLastModified. It has a value

Error in conversion of seconds since epoch to a date-time

2024-06-20 Thread James McMahon
Hello. I have a json key named viewLastModified. It has a value of 1652135219. Using an Epoch Converter manually ( https://www.epochconverter.com/), I expect to convert this with my Groovy script to something in this ballpark: GMT: Monday, May 9, 2022 10:26:59 PM Your time zone: Monday, May 9, 2022