I\'m trying to mock the DateTimeFormatter class. I\'ve done the following:
@RunWith(PowerMockRunner.class)
@PrepareForTest({DateTimeFormatter.class})
public
An alternative to mocking LocalDateTime.now() is to inject the clock into your class and change your (or add another) constructor like this:
AwesomeClass(DateTimeFormatter fmt, Clock clock) {
//instead of LocalDateTime now = LocalDateTime.now():
LocalDateTime now = LocalDateTime.now(clock);
}
Then in your test:
new AwesomeClass(formatter, Clock.fixed(the time you want here));