My requirement is that my scheduled service will run at every 60 mins. I have done that.
Now I want to be able to find the assets created in last 60 minutes, I was writing a query for the same.So i created
DateTime dt = new DateTime();
DateTime modified_last_run_date = dt.minusMinutes(60);
DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
String last_run_time =modified_last_run_date.toString(dtf);
if I print the last_run_time string to console I get -- "2015-08-19T17:38:36.221+0530"
However when I write Query : SELECT p.* FROM [dam:Asset] AS p WHERE p.[jcr:created] >= CAST('2015-08-19T17:38:36.221+0530' AS DATE) I get java.lang.IllegalArgumentException: Not a date string: 2015-08-19T17:38:36.221+0530
but if I write SELECT p.* FROM [dam:Asset] AS p WHERE p.[jcr:created] >= CAST('2015-08-19T17:38:36.221Z' AS DATE) I get no compilation error and query runs but with a lag of 5:30 hrs i mean i don't get correct results.
Can anybody suggest me solution.
In brief I want to find in each hourly run of my service which were the assets created since last run.
Solved! Go to Solution.
Views
Replies
Total Likes
as @siva mentioned, you need ':' to add in your time and your query should fetch you a result. You quickly try your query in 'tools -> query' in crxde
[img]Capture.JPG[/img]
Views
Replies
Total Likes
Did you try this SELECT p.* FROM [dam:Asset] AS p WHERE p.[jcr:created] >= CAST('2015-08-19T17:38:36.221+05:30' AS DATE)
Views
Replies
Total Likes
Try using the QueryBuilder API to perform this task - look at this older community thread - Justin give some advice
Views
Replies
Total Likes
as @siva mentioned, you need ':' to add in your time and your query should fetch you a result. You quickly try your query in 'tools -> query' in crxde
[img]Capture.JPG[/img]
Views
Replies
Total Likes
To fix this, update your pattern string to "yyyy-MM-dd'T'HH:mm:ss.SSSXXX".
Views
Replies
Total Likes
and to get ':' use this format yyyy-MM-dd'T'HH:mm:ss.SSSZZ
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies