"If your Java code has Date date = new Date(); buried in its guts, how do you set it to a known value you can then compare against in your tests? Well, you don't."
You don't if you aren't testing your code properly. If you are, one option is PowerMock.
You don't if you aren't testing your code properly. If you are, one option is PowerMock.
whenNew(Date.class).withNoArguments().thenReturn(someDateWeKnowAbout);