Convert epoch timestamp to normal timestamp in nifi - apache-nifi

I want to convert the epoch timestamp to a normal timestamp.
i have tried ${field.value:format('MM/dd/yyyy HH:mm:ss.SSS')} in update attribute it give some wrong date in 1970 for the value 1625777940

if you have epoch timestamp in seconds then converting it to java is simply multiply by 1000 because java counts time in milliseconds since 1/1/1970 (the same base as unix).
so, this should work:
${field.value:multiply(1000):format('MM/dd/yyyy HH:mm:ss.SSS')}

Related

Impala date subtraction timestamp and get the result in equivalent days irrespective of difference in hours or year or days or seconds

I want to subtract two date in impala. I know there is a datediff funciton in impala but if there is two timestamp value how to deal with it, like consider this situation:
select to_date('2022-01-01 15-05-53','yyyy-mm-dd HH24-mi-ss')-to_date('2022-01-01 15-04-53','yyyy-mm-dd HH24-mi-ss') from dual;
There is 1 minute difference and oracle would put the result as 0.000694444 days.
My requirement is if there is any such functionality in impala where I can subtract two timestamp value in the manner 'yyyy-mm-dd HH24-mi-ss', and get the result in equivalent days irrespective of if there is difference in days , year, hours, minute or seconds. Any difference should reflect in equivalent number of days.
Any other way where I can achieve the same thing, I am open to that as well.
Thank you in advance.
You can use unix_timestamp(timestamp) to convert both fields to unixtime (int) format. This is actually seconds from 1970-01-01 and very suitable to calculate date time differences in seconds. Once you have seconds from 1970-01-01, you can easily minus them both to know the differences.
Your sql should be like this -
select
unix_timestamp(to_timestamp('2022-01-01 15-06-53','yyyy-MM-dd HH-mm-ss')) -
unix_timestamp(to_timestamp('2022-01-01 15-05-53','yyyy-MM-dd HH-mm-ss')
) diff_in_seconds
Once youhave difference in seconds, you can easily convert them to minutes/hours/days - whatever format you want it.

What is the time format in chrome dev tools cache Expires/ Max-Age?

I noticed the time format in chrome cache expiry is in format of 2021-06-19T08:38:40.980Z.
I do not recognize this time format and cant find about its conversion to UTC. So, my question is what kind of time format is this one. And how to convert it to UTC?
That is the ISO 8601 extended date time format. It also conforms to the RFC 3339 timestamp format, and the ECMAScript date time string format. Basically, that's the standard, most preferred way to represent a timestamp (as a string) on the Internet.
The date part is in yyyy-MM-dd format (year, month, day).
The T stands for "Time" and separates the date part from the time part.
The time is in HH:mm:ss.fff format (hour of 24-hour clock, minute, seconds, fractional seconds - milliseconds in this case).
The Z stands for "Zulu", another name for UTC. It indicates that the date and time before it are represented in UTC.
Thus, you do not need to convert it. The value is already in UTC.

Pentaho kettle value conversion

I wanted to convert microseconds to data:
60000000 -> 1997-2-12 (something like this).
This means the new field contains year-month-day-hour-minute-seconds-microseconds
Thx.
microseconds (or any time span) can't be directly converted to a date, because you need a starting date and then add your timespan to that date, to end up with a calculated date. Quite often, timespans expressing dates are using the unix epoch start date of January 1st, 1970, 0:00 UTC as their base date.
To calculate your target date, you could use the Calculator step from Kettle. First reverse the sign of your microseconds timespan (multiply with -1), then use the calculation Date A - Date B (milliseconds) to calculate your new date.
as your new field is a Date field, you can format the output to your own specification.

Convert Unix Timestamp - Spotfire Analyst

I'm importing SQL data into Spotfire Analyst. All of the date and time fields are in the form of a Unix timestamp. What's the best way to convert this into an actual date format that I can manipulate in Spotfire?
Utilizing a calculated column you can calculate the datetime based on the UNIX epoch.
We simply add our seconds to the DateTime of the UNIX epoch (JAN 01 1970 00:00:00 UTC) to get the result. Below is an example of the UNIX time when I started writing this post.
DateAdd("second",1429733486,DateTime(1970,1,1,0,0,0,0))
The below is what should work for you:
DateAdd("second",[UNIX_TIMESTAMP_COLUMN],DateTime(1970,1,1,0,0,0,0))
Keep in mind these dates produced will be in the UTC timezone as per the JAN 1 1970 epoch. If you need them in your local time zone you may have to adjust accordingly with further DateAdd functions adding/subtracting time as per current conversions. Also, if you observe daylight savings time you may need to add some extra case logic to handle that as well.
Please let me know if you have any questions or need further clarification.
In 7.0 and later you can use
FromEpohTimeSeconds([UNIXDATE])
or
FromEpohTimeMilliseconds([UNIXDATE])

The format of the date is changed to make a reload in my jqGrid, my date format is changed

I have the date format in my jqGrid as: 08.13.2015 0:00
When running a procedural reload from ajax consulting my webService, my database returns the date in this format 2015-08-13T00: 00:00
I have never seen this format with the T.
ISO 8601 format of complete date, plus hours, minutes and seconds
The "T" indicates the beginning of the time sequence.

Resources