本文整理匯總了Java中java.time.Clock.systemDefaultZone方法的典型用法代碼示例。如果您正苦於以下問題:Java Clock.systemDefaultZone方法的具體用法?Java Clock.systemDefaultZone怎麽用?Java Clock.systemDefaultZone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.time.Clock
的用法示例。
在下文中一共展示了Clock.systemDefaultZone方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import java.time.Clock; //導入方法依賴的package包/類
/**
* Launch the application.
*
* @throws Exception
*/
public static void main(String[] args) throws Exception {
AppContext appContext = new AppContext(Clock.systemDefaultZone());
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
MainWindow window = new MainWindow(appContext);
window.show();
} catch (Exception e) {
JOptionPane.showMessageDialog(
null,
Throwables.getStackTraceAsString(e),
"error:" + e.getMessage(),
JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
}
}
});
}
示例2: testClock
import java.time.Clock; //導入方法依賴的package包/類
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());
}
示例3: registerExtenderCallbacks
import java.time.Clock; //導入方法依賴的package包/類
@Override
public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks) {
this.callbacks = callbacks;
this.helpers = callbacks.getHelpers();
callbacks.setExtensionName("ProxyHistoryWebUI");
try {
// ONLY THIS PATTERN WORK FINE. ?? ClassLoader.loadClass() NOT WORK... X(
Class.forName("org.h2.Driver");
appContext = new AppContext(Clock.systemDefaultZone());
appContext.setConsoleOutputWriter(new PrintWriter(callbacks.getStdout(), true));
appContext.setConsoleErrorWriter(new PrintWriter(callbacks.getStderr(), true));
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
demoPanel = new DemoPanel(appContext);
callbacks.customizeUiComponent(demoPanel);
callbacks.addSuiteTab(BurpExtender.this);
// register ourselves as an HTTP listener
callbacks.registerProxyListener(BurpExtender.this);
}
});
} catch (Exception e) {
callbacks.printError(Throwables.getStackTraceAsString(e));
e.printStackTrace();
}
}
示例4: initSystemComponents
import java.time.Clock; //導入方法依賴的package包/類
private void initSystemComponents(final SystemComponents systemComponents) {
client = systemComponents.client();
pluginConfig = systemComponents.pluginConfig();
infoStrategy = systemComponents.infoStrategy();
clientUtil = systemComponents.clientUtil();
zorro = new Zorro(pluginConfig);
clock = Clock.systemDefaultZone();
}
示例5: systemClock
import java.time.Clock; //導入方法依賴的package包/類
@Bean
public Clock systemClock() {
return Clock.systemDefaultZone();
}
示例6: dailyInterestAmountShouldEqualTwoPenniesFor100PoundsAnd8Percent
import java.time.Clock; //導入方法依賴的package包/類
@Test
public void dailyInterestAmountShouldEqualTwoPenniesFor100PoundsAnd8Percent() {
InterestCalculationService service = new InterestCalculationService(Clock.systemDefaultZone());
BigDecimal dailyAmount = service.calculateDailyAmountFor(
new BigDecimal("100.00"), EIGHT_PERCENT_INTEREST
);
assertThat(dailyAmount).isEqualTo("0.02");
}
開發者ID:hmcts,項目名稱:cmc-claim-store,代碼行數:11,代碼來源:InterestCalculationServiceDailyAmountCalculationTest.java
示例7: beforeEachTest
import java.time.Clock; //導入方法依賴的package包/類
@Before
public void beforeEachTest() {
provider = new DefendantPinLetterContentProvider(notificationsProperties,
new InterestContentProvider(
new InterestCalculationService(Clock.systemDefaultZone())
)
);
when(notificationsProperties.getFrontendBaseUrl()).thenReturn(FRONTEND_BASE_URL);
}
示例8: shouldThrowNullPointerWhenGivenNullAmount
import java.time.Clock; //導入方法依賴的package包/類
@Test(expected = NullPointerException.class)
public void shouldThrowNullPointerWhenGivenNullAmount() {
InterestCalculationService service = new InterestCalculationService(Clock.systemDefaultZone());
service.calculateDailyAmountFor(null, HUNDRED_PERCENT_INTEREST);
}
開發者ID:hmcts,項目名稱:cmc-claim-store,代碼行數:6,代碼來源:InterestCalculationServiceDailyAmountCalculationTest.java
示例9: shouldThrowNullPointerWhenGivenNullInterest
import java.time.Clock; //導入方法依賴的package包/類
@Test(expected = NullPointerException.class)
public void shouldThrowNullPointerWhenGivenNullInterest() {
InterestCalculationService service = new InterestCalculationService(Clock.systemDefaultZone());
service.calculateDailyAmountFor(BigDecimal.TEN, null);
}
開發者ID:hmcts,項目名稱:cmc-claim-store,代碼行數:6,代碼來源:InterestCalculationServiceDailyAmountCalculationTest.java
示例10: setup
import java.time.Clock; //導入方法依賴的package包/類
@Before
public void setup() {
this.provider = new ContentProvider(new InterestCalculationService(Clock.systemDefaultZone()));
}
示例11: TimeBasedCache
import java.time.Clock; //導入方法依賴的package包/類
TimeBasedCache(Duration minTimeBetweenReloads, Supplier<Map<K, V>> valuesSupplier)
{
this(minTimeBetweenReloads, valuesSupplier, Collections.emptyMap(), Clock.systemDefaultZone());
}
示例12: eventSource
import java.time.Clock; //導入方法依賴的package包/類
@Override
public EventSource eventSource() {
return new FlatFilesystemEventSource(folder.getRoot().toPath(), Clock.systemDefaultZone(), ".json");
}
示例13: clock
import java.time.Clock; //導入方法依賴的package包/類
@Bean
public Clock clock() {
return Clock.systemDefaultZone();
}
示例14: RequestStatusLoggingFilter
import java.time.Clock; //導入方法依賴的package包/類
public RequestStatusLoggingFilter() {
this(Clock.systemDefaultZone());
}
示例15: getSystemClock
import java.time.Clock; //導入方法依賴的package包/類
@Provides
private Clock getSystemClock() {
return Clock.systemDefaultZone();
}