test/java/time/tck/java/time/TCKClock.java

Print this page




  66 import org.testng.annotations.Test;
  67 
  68 /**
  69  * Test Clock.
  70  */
  71 @Test
  72 public class TCKClock {
  73 
  74     static class MockInstantClock extends Clock {
  75         final long millis;
  76         final ZoneId zone;
  77         MockInstantClock(long millis, ZoneId zone) {
  78             this.millis = millis;
  79             this.zone = zone;
  80         }
  81         @Override
  82         public long millis() {
  83             return millis;
  84         }
  85         @Override




  86         public ZoneId getZone() {
  87             return zone;
  88         }
  89         @Override
  90         public Clock withZone(ZoneId timeZone) {
  91             return new MockInstantClock(millis, timeZone);
  92         }
  93         @Override
  94         public boolean equals(Object obj) {
  95             return false;
  96         }
  97         @Override
  98         public int hashCode() {
  99             return 0;
 100         }
 101         @Override
 102         public String toString() {
 103             return "Mock";
 104         }
 105     }




  66 import org.testng.annotations.Test;
  67 
  68 /**
  69  * Test Clock.
  70  */
  71 @Test
  72 public class TCKClock {
  73 
  74     static class MockInstantClock extends Clock {
  75         final long millis;
  76         final ZoneId zone;
  77         MockInstantClock(long millis, ZoneId zone) {
  78             this.millis = millis;
  79             this.zone = zone;
  80         }
  81         @Override
  82         public long millis() {
  83             return millis;
  84         }
  85         @Override
  86         public Instant instant() {
  87             return Instant.ofEpochMilli(millis());
  88         }
  89         @Override
  90         public ZoneId getZone() {
  91             return zone;
  92         }
  93         @Override
  94         public Clock withZone(ZoneId timeZone) {
  95             return new MockInstantClock(millis, timeZone);
  96         }
  97         @Override
  98         public boolean equals(Object obj) {
  99             return false;
 100         }
 101         @Override
 102         public int hashCode() {
 103             return 0;
 104         }
 105         @Override
 106         public String toString() {
 107             return "Mock";
 108         }
 109     }