当前位置: 首页>>代码示例>>Java>>正文


Java LocalTime.now方法代码示例

本文整理汇总了Java中java.time.LocalTime.now方法的典型用法代码示例。如果您正苦于以下问题:Java LocalTime.now方法的具体用法?Java LocalTime.now怎么用?Java LocalTime.now使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.time.LocalTime的用法示例。


在下文中一共展示了LocalTime.now方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: EditorDialog

import java.time.LocalTime; //导入方法依赖的package包/类
/**
 * Instantiates a new Editor dialog.
 */
public EditorDialog() {
    this.showedTime = LocalTime.now();

    container = new VBox();
    container.setAlignment(CENTER);

    final EditorConfig editorConfig = EditorConfig.getInstance();
    final CssColorTheme theme = editorConfig.getTheme();

    final Scene scene = new Scene(container);
    final ObservableList<String> stylesheets = scene.getStylesheets();
    stylesheets.addAll(CSS_REGISTRY.getAvailableCssFiles());
    stylesheets.add(theme.getCssFile());

    createControls(container);

    dialog = new Stage();
    dialog.setTitle(getTitleText());
    dialog.initStyle(StageStyle.UTILITY);
    dialog.initModality(Modality.WINDOW_MODAL);
    dialog.setResizable(isResizable());
    dialog.setScene(scene);

    configureSize(container);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:29,代码来源:EditorDialog.java

示例2: submit

import java.time.LocalTime; //导入方法依赖的package包/类
public void submit(Config config, Runnable command){
    if (appsHashMap.containsKey(config)){
        log.info("App: {} already monitored", config);
        return;
    }
    String[] strategy = config.getStrategy();
    Future result=null;
    switch (strategy[0]){
        case "replay":
            result = scheduleAtFixedRate(command,0, Long.parseLong(strategy[1]),TimeUnit.SECONDS);
            break;
        case "fixed":
            String[] spliteTime = strategy[1].split(":");
            LocalTime scheduledTime = LocalTime.of(Integer.parseInt(spliteTime[0]),Integer.parseInt(spliteTime[1]));
            LocalTime now = LocalTime.now();
            long delay = Duration.between(now,scheduledTime).getSeconds();
            result = scheduleAtFixedRate(command,delay>0?delay:24*60*60+delay, 24*60*60L,TimeUnit.SECONDS);
            break;
        default: break;
    }
    appsHashMap.put(config,result);
    log.debug("task account:{}",super.getTaskCount());
    log.debug("task active account:{}",super.getActiveCount());
    log.debug("task complete account:{}",super.getCompletedTaskCount());
}
 
开发者ID:huang-kai,项目名称:auto-scale-java,代码行数:26,代码来源:TaskScheduledThreadPool.java

示例3: main

import java.time.LocalTime; //导入方法依赖的package包/类
public static void main(String[] args) {
    // Hours, minutes
    LocalTime timeHrsMin = LocalTime.of(12, 12);
    // Hours, minutes and seconds
    LocalTime timeHrsMinSec = LocalTime.of(0, 12, 6);
    // Hours, minutes, seconds and nanoseconds
    LocalTime timeHrsMinSecNano = LocalTime.of(14, 7, 10, 998654578);

    // DateTimeException
    //LocalTime timeHrsMin1 = LocalTime.of(120, 12);// Runtime exception
    //LocalTime timeHrsMin2 = LocalTime.of(9986545781, 12);// Compilation error

    // To get the current time from the system clock, use the static method now()
    LocalTime date3 = LocalTime.now();

    // Parse a string to instantiate LocalTime by using its static method parse()
    LocalTime time = LocalTime.parse("15:08:23");


}
 
开发者ID:huby,项目名称:java-se8-oca-study-guide,代码行数:21,代码来源:Main.java

示例4: shouldChangeInterval

import java.time.LocalTime; //导入方法依赖的package包/类
@Test
public void shouldChangeInterval() {
    LocalDate startDate = LocalDate.now().plusDays(1);
    LocalDate endDate = LocalDate.now().plusDays(2);

    LocalTime startTime = LocalTime.now();
    LocalTime endTime = LocalTime.now().plusHours(10);

    Interval interval = new Interval(startDate, startTime, endDate, endTime,
            ZoneId.of("UTC"));

    entry.setInterval(interval);

    assertThat(entry.getStartDate(), is(equalTo(startDate)));
    assertThat(entry.getStartTime(), is(equalTo(startTime)));
    assertThat(entry.getEndDate(), is(equalTo(endDate)));
    assertThat(entry.getEndTime(), is(equalTo(endTime)));
    assertThat(entry.getZoneId(), is(equalTo(ZoneId.of("UTC"))));
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:20,代码来源:EntryTest.java

示例5: main

import java.time.LocalTime; //导入方法依赖的package包/类
/**
 * 程序执行入口.
 *
 * @param args 命令行参数
 */
public static void main(String[] args) {

    LocalTime time = LocalTime.now();// |\longremark{获取当前时间}|
    System.out.println("Current Time=" + time);

    LocalTime specificTime = LocalTime.of(12, 20, 25, 40); // |\longremark{根据给定时间创建时间对象}|
    System.out.println("Specific Time of Day=" + specificTime);

    LocalTime timeShanghai = LocalTime.now(ZoneId.of("Asia/Shanghai")); // |\longremark{根据给定时区创建时间对象}|
    System.out.println("Current Time in CST=" + timeShanghai);

    //Getting date from the base date i.e 01/01/1970
    LocalTime specificSecondTime = LocalTime.ofSecondOfDay(10000);// |\longremark{获得从1970-1-1开始计算的时间}|
    System.out.println("10000th second time= " + specificSecondTime);

    LocalTime one = LocalTime.parse("12:30:55"); //|\longremark{将字符串解析为LocalTime对象}|
    LocalTime two = LocalTime.parse("13:02:15");
    //LocalTime three = LocalTime.parse("2016-1-1 13:02:15"); // 格式错误
    System.out.println("12:30:55 parsed to LocalDate = " + one);
    System.out.println("12:30:55 < 13:02:15 ? " + one.isBefore(two));
    System.out.println("12:30:55 < 12:30:55 ? " + one.isBefore(one));
    System.out.println("13:02:15 > 12:30:55 ? " + two.isAfter(one));
}
 
开发者ID:subaochen,项目名称:java-tutorial,代码行数:29,代码来源:LocalTimeTest.java

示例6: setLocalTime

import java.time.LocalTime; //导入方法依赖的package包/类
@Test
public void setLocalTime() {
  final LocalTime value = LocalTime.now();
  final Iterator<Value<?>> it = ps.setLocalTime(value).params().iterator();
  assertEquals(new LocalTimeValue(value), it.next());
  assertFalse(it.hasNext());
}
 
开发者ID:traneio,项目名称:ndbc,代码行数:8,代码来源:PreparedStatementTest.java

示例7: setLocalTimePositional

import java.time.LocalTime; //导入方法依赖的package包/类
@Test
public void setLocalTimePositional() {
  final LocalTime value = LocalTime.now();
  final Iterator<Value<?>> it = ps.setLocalTime(0, value).params().iterator();
  assertEquals(new LocalTimeValue(value), it.next());
  assertFalse(it.hasNext());
}
 
开发者ID:traneio,项目名称:ndbc,代码行数:8,代码来源:PreparedStatementTest.java

示例8: now_ZoneId

import java.time.LocalTime; //导入方法依赖的package包/类
@Test
public void now_ZoneId() {
    ZoneId zone = ZoneId.of("UTC+01:02:03");
    LocalTime expected = LocalTime.now(Clock.system(zone));
    LocalTime test = LocalTime.now(zone);
    for (int i = 0; i < 100; i++) {
        if (expected.equals(test)) {
            return;
        }
        expected = LocalTime.now(Clock.system(zone));
        test = LocalTime.now(zone);
    }
    assertEquals(test, expected);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:TCKLocalTime.java

示例9: actionPerformed

import java.time.LocalTime; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
	LocalTime localeTime = LocalTime.now();

	int hour = localeTime.getHour();
	int minute = localeTime.getMinute();
	int second = localeTime.getSecond();

	timeText.setText(String.format("%02d : %02d : %02d", hour, minute, second));
}
 
开发者ID:AitorB,项目名称:POPBL_V,代码行数:11,代码来源:Time.java

示例10: accept

import java.time.LocalTime; //导入方法依赖的package包/类
@Override
public boolean accept(Media candidate) {
    LocalTime now = LocalTime.now(clock);
    if (begin.isBefore(stop)) {
        return logAndReturn(begin.isBefore(now) && now.isBefore(stop), now);
    } else {
        return logAndReturn((
                now.isAfter(begin) && now.isAfter(stop)) || (now.isBefore(stop) && now.isBefore(begin)), now);
    }
}
 
开发者ID:ccremer,项目名称:clustercode,代码行数:11,代码来源:TimeConstraint.java

示例11: shouldFailBecauseOfBadDates

import java.time.LocalTime; //导入方法依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void shouldFailBecauseOfBadDates() {
    // given
    LocalDate startDate = LocalDate.now();
    LocalDate endDate = LocalDate.now().minusDays(1);

    // when
    new Interval(startDate, LocalTime.now(), endDate, LocalTime.now(), ZoneId.systemDefault());

    // then
    // throw exception
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:13,代码来源:IntervalTest.java

示例12: shouldFailBecauseOfBadTimes

import java.time.LocalTime; //导入方法依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void shouldFailBecauseOfBadTimes() {
    // given
    LocalDate startDate = LocalDate.now();
    LocalDate endDate = startDate;

    // when
    new Interval(startDate, LocalTime.now(), endDate, LocalTime.now().minusHours(1), ZoneId.systemDefault());

    // then
    // throw exception
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:13,代码来源:IntervalTest.java

示例13: now_Clock_min

import java.time.LocalTime; //导入方法依赖的package包/类
@Test
public void now_Clock_min() {
    Clock clock = Clock.fixed(Instant.MIN, ZoneOffset.UTC);
    LocalTime test = LocalTime.now(clock);
    assertEquals(test.getHour(), 0);
    assertEquals(test.getMinute(), 0);
    assertEquals(test.getSecond(), 0);
    assertEquals(test.getNano(), 0);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:TCKLocalTime.java

示例14: notifyShowed

import java.time.LocalTime; //导入方法依赖的package包/类
@Override
@FXThread
public void notifyShowed() {
    this.showedTime = LocalTime.now();

    final EditorDescription description = getDescription();
    GAnalytics.sendPageView(description.getEditorId(), null, "/editing/" + description.getEditorId());
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:9,代码来源:AbstractFileEditor.java

示例15: openFile

import java.time.LocalTime; //导入方法依赖的package包/类
@Override
@FXThread
public void openFile(@NotNull final Path file) {
    FX_EVENT_MANAGER.addEventHandler(FileChangedEvent.EVENT_TYPE, getFileChangedHandler());

    this.file = file;
    this.showedTime = LocalTime.now();

    final EditorDescription description = getDescription();

    GAnalytics.sendEvent(GAEvent.Category.EDITOR, GAEvent.Action.EDITOR_OPENED,
            description.getEditorId() + "/" + getFileName());

    GAnalytics.sendPageView(description.getEditorId(), null, "/editing/" + description.getEditorId());
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:16,代码来源:AbstractFileEditor.java


注:本文中的java.time.LocalTime.now方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。