Is Workflow.currentTimeMillis() the same as Workflow.sideEffect(System::currentTimeMillis)?

Hello,

The question is self-explanatory.

If you’ re wondering why would anyone use “Workflow.sideEffect(System::currentTimeMillis)” the answer is that we can put arbitrary method inside of side effect, that could be mocked for testing purposes.

I’ve checked the docs. Not completely sure, but it seems like Workflow.currentTimeMillis() would return time according to temporal’s servers? Does this mean that our workflows could work well even if our own internal machines get out of sync?

yes its the timestamp of the workflow task (set by server when it dispatches task to your worker) within which you make the api call. so it will be deterministic across workers

SideEffect is added to the history as an event when currentTimeMillis doesn’t need this.

Thank you for the clarification!