本文整理了Java中org.threeten.bp.LocalDateTime.now()
方法的一些代码示例,展示了LocalDateTime.now()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDateTime.now()
方法的具体详情如下:
包路径:org.threeten.bp.LocalDateTime
类名称:LocalDateTime
方法名:now
[英]Obtains the current date-time from the system clock in the default time-zone.
This will query the Clock#systemDefaultZone() in the default time-zone to obtain the current date-time.
Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.
[中]从默认时区中的系统时钟获取当前日期时间。
这将查询默认时区中的时钟#systemDefaultZone(),以获取当前日期时间。
使用此方法将防止使用备用时钟进行测试,因为该时钟是硬编码的。
代码示例来源:origin: ThreeTen/threetenbp
/**
* Obtains the current date-time from the system clock in the specified time-zone.
* <p>
* This will query the {@link Clock#system(ZoneId) system clock} to obtain the current date-time.
* Specifying the time-zone avoids dependence on the default time-zone.
* <p>
* Using this method will prevent the ability to use an alternate clock for testing
* because the clock is hard-coded.
*
* @param zone the zone ID to use, not null
* @return the current date-time using the system clock, not null
*/
public static LocalDateTime now(ZoneId zone) {
return now(Clock.system(zone));
}
代码示例来源:origin: org.threeten/threetenbp
/**
* Obtains the current date-time from the system clock in the default time-zone.
* <p>
* This will query the {@link Clock#systemDefaultZone() system clock} in the default
* time-zone to obtain the current date-time.
* <p>
* Using this method will prevent the ability to use an alternate clock for testing
* because the clock is hard-coded.
*
* @return the current date-time using the system clock and default time-zone, not null
*/
public static LocalDateTime now() {
return now(Clock.systemDefaultZone());
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* Obtains the current date-time from the system clock in the default time-zone.
* <p>
* This will query the {@link Clock#systemDefaultZone() system clock} in the default
* time-zone to obtain the current date-time.
* <p>
* Using this method will prevent the ability to use an alternate clock for testing
* because the clock is hard-coded.
*
* @return the current date-time using the system clock and default time-zone, not null
*/
public static LocalDateTime now() {
return now(Clock.systemDefaultZone());
}
代码示例来源:origin: org.threeten/threetenbp
/**
* Obtains the current date-time from the system clock in the specified time-zone.
* <p>
* This will query the {@link Clock#system(ZoneId) system clock} to obtain the current date-time.
* Specifying the time-zone avoids dependence on the default time-zone.
* <p>
* Using this method will prevent the ability to use an alternate clock for testing
* because the clock is hard-coded.
*
* @param zone the zone ID to use, not null
* @return the current date-time using the system clock, not null
*/
public static LocalDateTime now(ZoneId zone) {
return now(Clock.system(zone));
}
代码示例来源:origin: riggaroo/android-things-electricity-monitor
private Duration getDifferenceBetweenTimeAndNow(long timeStart) {
LocalDateTime today = LocalDateTime.now();
LocalDateTime otherTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timeStart), ZoneId.systemDefault());
return Duration.between(otherTime, today);
}
代码示例来源:origin: net.oneandone.ical4j/ical4j
startDate = zoneOffsetTransition.getDateTimeBefore();
} else {
startDate = LocalDateTime.now(zoneId);
int transitionRuleMonthValue = transitionRule.getMonth().getValue();
DayOfWeek transitionRuleDayOfWeek = transitionRule.getDayOfWeek();
LocalDateTime ldt = LocalDateTime.now(zoneId)
.with(TemporalAdjusters.firstInMonth(transitionRuleDayOfWeek))
.withMonth(transitionRuleMonthValue)
内容来源于网络,如有侵权,请联系作者删除!