Java Code Examples for java.time.Clock#systemDefaultZone()
The following examples show how to use
java.time.Clock#systemDefaultZone() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TinkerPopOperations.java From timbuctoo with GNU General Public License v3.0 | 6 votes |
private TinkerPopOperations(TinkerPopGraphManager graphManager, Function<IndexHandler, ChangeListener> listener, Function<IndexHandler, GremlinEntityFetcher> entityFetcher, Vres mappings, IndexHandler indexHandler) { graph = graphManager.getGraph(); this.transaction = graph.tx(); if (transaction.isOpen()) { ownTransaction = false; LOG.error("There is already an open transaction", new Throwable()); //exception for the stack trace } else { ownTransaction = true; transaction.open(); } this.indexHandler = indexHandler; this.listener = listener.apply(indexHandler); this.entityFetcher = entityFetcher.apply(indexHandler); this.traversal = graph.traversal(); this.latestState = graphManager.getLatestState(); this.mappings = mappings == null ? loadVres() : mappings; this.systemPropertyModifier = new SystemPropertyModifier(Clock.systemDefaultZone()); this.graphDatabase = graphManager.getGraphDatabase(); //FIXME move to IndexHandler }
Example 2
Source File: TimeIntroduction.java From util4j with Apache License 2.0 | 6 votes |
public static void testClock() throws InterruptedException { //时钟提供给我们用于访问某个特定 时区的 瞬时时间、日期 和 时间的。 Clock c1 = Clock.systemUTC(); //系统默认UTC时钟(当前瞬时时间 System.currentTimeMillis()) System.out.println(c1.millis()); //每次调用将返回当前瞬时时间(UTC) Clock c2 = Clock.systemDefaultZone(); //系统默认时区时钟(当前瞬时时间) Clock c31 = Clock.system(ZoneId.of("Europe/Paris")); //巴黎时区 System.out.println(c31.millis()); //每次调用将返回当前瞬时时间(UTC) Clock c32 = Clock.system(ZoneId.of("Asia/Shanghai"));//上海时区 System.out.println(c32.millis());//每次调用将返回当前瞬时时间(UTC) Clock c4 = Clock.fixed(Instant.now(), ZoneId.of("Asia/Shanghai"));//固定上海时区时钟 System.out.println(c4.millis()); Thread.sleep(1000); System.out.println(c4.millis()); //不变 即时钟时钟在那一个点不动 Clock c5 = Clock.offset(c1, Duration.ofSeconds(2)); //相对于系统默认时钟两秒的时钟 System.out.println(c1.millis()); System.out.println(c5.millis()); }
Example 3
Source File: TimbuctooActionsStubs.java From timbuctoo with GNU General Public License v3.0 | 5 votes |
public static TimbuctooActions withDataStore(DataStoreOperations dataStoreOperations) { return new TimbuctooActions( mock(PermissionFetcher.class), Clock.systemDefaultZone(), mock(RedirectionService.class), (coll, id, rev) -> URI.create("http://example.org/persistent"), dataStoreOperations, new AfterSuccessTaskExecutor() ); }
Example 4
Source File: CompactionService.java From synapse with Apache License 2.0 | 5 votes |
public CompactionService(final SnapshotWriteService snapshotWriteService, final StateRepository<String> stateRepository, final EventSourceBuilder eventSourceBuilder, final MessageLogReceiverEndpointFactory messageLogReceiverEndpointFactory) { this(snapshotWriteService, stateRepository, eventSourceBuilder, messageLogReceiverEndpointFactory, Clock.systemDefaultZone()); }
Example 5
Source File: ProtectedMailboxStorageEntryTest.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
private static ProtectedMailboxStorageEntry buildProtectedMailboxStorageEntry( MailboxStoragePayload mailboxStoragePayload, KeyPair ownerKey, PublicKey receiverKey, int sequenceNumber) throws CryptoException { byte[] hashOfDataAndSeqNr = P2PDataStorage.get32ByteHash(new P2PDataStorage.DataAndSeqNrPair(mailboxStoragePayload, sequenceNumber)); byte[] signature = Sig.sign(ownerKey.getPrivate(), hashOfDataAndSeqNr); return new ProtectedMailboxStorageEntry(mailboxStoragePayload, ownerKey.getPublic(), sequenceNumber, signature, receiverKey, Clock.systemDefaultZone()); }
Example 6
Source File: WorkspaceActivityChecker.java From che with Eclipse Public License 2.0 | 5 votes |
@Inject public WorkspaceActivityChecker( WorkspaceActivityDao activityDao, WorkspaceManager workspaceManager, WorkspaceRuntimes workspaceRuntimes, WorkspaceActivityManager workspaceActivityManager) { this( activityDao, workspaceManager, workspaceRuntimes, workspaceActivityManager, Clock.systemDefaultZone()); }
Example 7
Source File: KidBankApplication.java From kid-bank with Apache License 2.0 | 4 votes |
@Bean public Clock clock() { return Clock.systemDefaultZone(); }
Example 8
Source File: DailySheetConfiguration.java From library with MIT License | 4 votes |
@Bean DailySheet sheetsReadModel(JdbcTemplate jdbcTemplate) { return new SheetsReadModel(jdbcTemplate, Clock.systemDefaultZone()); }
Example 9
Source File: EntityFinisherHelper.java From timbuctoo with GNU General Public License v3.0 | 4 votes |
public EntityFinisherHelper() { this((collection, id, rev) -> URI.create("http://example.org"), Clock.systemDefaultZone(), "rdf-importer"); }
Example 10
Source File: Application.java From cqrs-hotel with Apache License 2.0 | 4 votes |
@Bean public Clock clock() { return Clock.systemDefaultZone(); }
Example 11
Source File: Timer.java From Neo4jSNA with Apache License 2.0 | 4 votes |
protected Timer() { clock = Clock.systemDefaultZone(); }
Example 12
Source File: TCKClock_System.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public void test_systemDefaultZone() { Clock test = Clock.systemDefaultZone(); assertEquals(test.getZone(), ZoneId.systemDefault()); assertEquals(test, Clock.system(ZoneId.systemDefault())); }
Example 13
Source File: MockedMetricsEndpointSpringApplication.java From promregator with Apache License 2.0 | 4 votes |
@Bean public Clock clock() { return Clock.systemDefaultZone(); }
Example 14
Source File: PersonGenerator.java From immutables with Apache License 2.0 | 4 votes |
public PersonGenerator() { this(Clock.systemDefaultZone()); }
Example 15
Source File: TCKClock_System.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public void test_systemDefaultZone() { Clock test = Clock.systemDefaultZone(); assertEquals(test.getZone(), ZoneId.systemDefault()); assertEquals(test, Clock.system(ZoneId.systemDefault())); }
Example 16
Source File: WebDriverWait.java From selenium with Apache License 2.0 | 3 votes |
/** * Wait will ignore instances of NotFoundException that are encountered (thrown) by default in * the 'until' condition, and immediately propagate all others. You can add more to the ignore * list by calling ignoring(exceptions to add). * * @param driver The WebDriver instance to pass to the expected conditions * @param timeout The timeout when an expectation is called * @see WebDriverWait#ignoring(java.lang.Class) */ public WebDriverWait(WebDriver driver, Duration timeout) { this( driver, timeout, Duration.ofMillis(DEFAULT_SLEEP_TIMEOUT), Clock.systemDefaultZone(), Sleeper.SYSTEM_SLEEPER); }
Example 17
Source File: AjaxElementLocator.java From selenium with Apache License 2.0 | 3 votes |
/** * Use this constructor in order to process custom annotaions. * * @param context The context to use when finding the element * @param timeOutInSeconds How long to wait for the element to appear. Measured in seconds. * @param annotations AbstractAnnotations class implementation */ public AjaxElementLocator( SearchContext context, int timeOutInSeconds, AbstractAnnotations annotations) { this(Clock.systemDefaultZone(), context, timeOutInSeconds, annotations); }
Example 18
Source File: ClockUnitTest.java From tutorials with MIT License | 3 votes |
@Test public void givenClock_usingOffset_retrievesFutureDate() { Clock baseClock = Clock.systemDefaultZone(); // result clock will be later than baseClock Clock futureClock = Clock.offset(baseClock, Duration.ofHours(72)); assertEquals(futureClock.instant().equals(null), false); assertTrue(futureClock.millis() > baseClock.millis()); LOGGER.debug("Future Clock instant :: " + futureClock.instant()); }
Example 19
Source File: ClockUnitTest.java From tutorials with MIT License | 3 votes |
@Test public void givenClock_withSytemUTC_retrievesTimeInMillis() { Clock clockMillis = Clock.systemDefaultZone(); assertEquals(clockMillis.instant().equals(null), false); assertTrue(clockMillis.millis() > 0); LOGGER.debug("System Default millis :: " + clockMillis.millis()); }
Example 20
Source File: AjaxElementLocator.java From selenium with Apache License 2.0 | 2 votes |
/** * Main constructor. * * @param searchContext The context to use when finding the element * @param field The field representing this element * @param timeOutInSeconds How long to wait for the element to appear. Measured in seconds. */ public AjaxElementLocator(SearchContext searchContext, Field field, int timeOutInSeconds) { this(Clock.systemDefaultZone(), searchContext, field, timeOutInSeconds); }