Mock current date

For testing purposes and building history I need to mock the date

What is the best approach?

is unit testing - How to mock new Date() in java using Mockito - Stack Overflow
a feasible approach?

look forward to your suggestions,


Most of the OOTB code uses ec.user.nowTimestamp() for the current date/time, and this is partly to make it easier to test with different dates/times. This approach is used in the OOTB service level tests in mantle-usl, such as this call to ec.user.setEffectiveTime():

1 Like

excellent, works very well, thanks David!

1 Like