Getting Data In

Groovy - Date Format

meduriphani
New Member

Hi,

This would be very useful If I get any example.

I am using Groovy to retrieve savedSearch results. My code is continuously failing because of data format.

         def etime=request.headers.get("earliestTime")
         def ltime=request.headers.get("LatestTime")
          dispatchArgs.setDispatchTimeFormat("yyyy-MM-dd'T'HH:mm:ss.mmm-05:00")
          dispatchArgs.setDispatchEarliestTime(etime)
          dispatchArgs.setDispatchLatestTime(ltime)
         Job job = savedSearch.dispatch(dispatchArgs)

I am getting the earliestTime and LatestTime in the date-format of pattern="yyyy-MM-dd'T'HH:mm:ss.mmm-05:00".

It would be helpful If you point where the above code going wrong. OR practical any example.

I referenced the above code from http://dev.splunk.com/view/java-sdk/SP-CAAAEKY

Thanks,
Phanendra Meduri

Tags (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Your time format string is in neither the Groovy nor Splunk format. Try either "yyyy-MM-dd'T'HH:mm:ss.SSSX" or "%Y-%m-%dT%H:%M:%S.%3N%z".

---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Your time format string is in neither the Groovy nor Splunk format. Try either "yyyy-MM-dd'T'HH:mm:ss.SSSX" or "%Y-%m-%dT%H:%M:%S.%3N%z".

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...