Ask Your Question
1

How do I calculate an offset from time now and format it as a string?

asked 2019-06-05 08:20:59 -0500

spadez8 gravatar image

updated 2019-06-10 10:20:54 -0500

metadaddy gravatar image

Hi,

I'm looking at this thread: https://ask.streamsets.com/question/2...

Helpfully this code was posted:

${time:millisecondsToDateTime(time:dateTimeToMilliseconds(time:now()) - (4 * 3600 * 1000))}

However, I can't get this in this format:

yyyy-MM-dd\'T\'HH:mm:ss.SSS

I tried this but it said it was invalid. Is there a way to do this?

${time:millisecondsToDateTime(time:dateTimeToMilliseconds(time:now()) - (4 * 3600 * 1000)),'UTC', 'yyyy-MM-dd\'T\'HH:mm:ss.SSS')}
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-06-10 10:19:06 -0500

metadaddy gravatar image

You were on the right lines; you just need to add time:extractStringFromDateTZ() to the mix:

${time:extractStringFromDateTZ(time:millisecondsToDateTime(time:dateTimeToMilliseconds(time:now()) - (4 * 3600 * 1000)), 'UTC', 'yyyy-MM-dd\'T\'HH:mm:ss.SSS')}
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-06-05 08:20:59 -0500

Seen: 341 times

Last updated: Jun 10