Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Date to milliseconds or validate which date is greater

Date to milliseconds or validate which date is greater

New Contributor

I am making an api and I found this problem: I am using a HandleHttpRequest, when entering the url of the api I receive a start date and end date with this format: yyyy-mm-dd hh: mm.

I need to do it is a RouteOnAttribute that validates if start is less than end, if it is so the flow continues but if it is greater than it shows a message to the user that he misplaced the dates in the url.

If this is successful, I need to validate that the difference in days between the start date and the end date is not greater than 7 days. I'm trying to pass the dates to milliseconds but I do not know why I can not. The parameters that I receive are $ {http.params.start} and $ {http.params.end}, I am trying to do it with: toNumer () but they are always empty, I do not return those dates in milliseconds. How could I solve this? Already with the two dates in milliseconds could validate, calculate the difference of days, etc. (I started using Nifi 2 days ago, excuse me if it's a very basic question)

1 REPLY 1
Highlighted

Re: Date to milliseconds or validate which date is greater

New Contributor

Try the example below. For your case, change the date format to fit what you need

${dateA:toDate("yyyy-MM-dd'T'HH:mm:ss.sss"):format('yyyyMMddHHmmsssss'):toString():lt(${dateB:toDate("yyyy-MM-dd'T'HH:mm:ss.sss"):format('yyyyMMddHHmmsssss'):toString()}