nifi-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Payne <marka...@hotmail.com>
Subject Re: Getting a timestamp for today at midnight?
Date Fri, 16 Nov 2018 21:21:53 GMT
Is that using the correct time zone? I.e., what if you print it out using:

DateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
System.out.println(sdf.format(new Date(myTimeAsLong)));

On Nov 16, 2018, at 4:16 PM, l vic <lvic4594@gmail.com<mailto:lvic4594@gmail.com>>
wrote:

That returns timestamp corresponding to 19:00PM
For example:
long myTimeAsLong=1542326400000L; // from NiFi
DateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
System.out.println(sdf.format(new Date(myTimeAsLong)));

prints out 2018/11/15 19:00:00

On Wed, Nov 14, 2018 at 9:21 AM Mark Payne <markap14@hotmail.com<mailto:markap14@hotmail.com>>
wrote:
You should be able to do something like:

${now():divide( 86400000 ):multiply( 86400000)}

I.e., use integer division to divide by number of milliseconds in a day, which gives you
the number of days since epoch. Then multiply by 86,400,000 again to convert from
days back to milliseconds. While it looks immediately like it would do nothing, the thing
to keep in mind is that the divide() function performs and Integer Division operation,
not a Decimal Division, so all decimals would be dropped, which essentially results in
all hours/mins/seconds/milliseconds getting dropped.

Thanks
-Mark


> On Nov 14, 2018, at 9:01 AM, l vic <lvic4594@gmail.com<mailto:lvic4594@gmail.com>>
wrote:
>
> I have to retrieve "today's" records in ExecuteSQL, eg. with the query using timestamp
"ts" column in table where ts type is "epoch" time as long integer :
> select * from mytable where ts >= midnight-timestamp-value
> Any idea how i can use "now()" function to get today's timestamp value at midnight?
> Thank you,



Mime
View raw message