Created
December 10, 2015 09:29
-
-
Save relax-more/eeaf2ae442b7907e55e1 to your computer and use it in GitHub Desktop.
Java Clock.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Named | |
public class Service(){ | |
Clock clock; | |
public Service(Clock clock){ | |
this.clock = clock; | |
} | |
public void work(){ | |
System.Out.plintln("time:" + Instant.now(clock)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Clock clock = Clock.fixed(Instant.parse("2015-01-01T00:00:00Z"), ZoneId.systemDefault()); | |
Service service; | |
@Before | |
public void before(){ | |
service = new Service(clock); | |
} | |
@Test | |
public void test(){ | |
service.work(); // shown 2015-01. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment