- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中java.time.ZoneId.from()
方法的一些代码示例,展示了ZoneId.from()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneId.from()
方法的具体详情如下:
包路径:java.time.ZoneId
类名称:ZoneId
方法名:from
[英]Obtains an instance of ZoneId from a temporal object.
A TemporalAccessor represents some form of date and time information. This factory converts the arbitrary temporal object to an instance of ZoneId.
The conversion will try to obtain the zone in a way that favours region-based zones over offset-based zones using TemporalQueries#zone().
This method matches the signature of the functional interface TemporalQueryallowing it to be used in queries via method reference, ZoneId::from.
[中]从时间对象获取ZoneId的实例。
临时助理代表某种形式的日期和时间信息。该工厂将任意时态对象转换为ZoneId的实例。
转换将尝试使用TemporalQueries#zone()以支持基于区域的分区而不是基于偏移的分区的方式获取分区。
此方法匹配函数接口TemporalQueryLow的签名,通过方法引用ZoneId::from将其用于查询。
代码示例来源:origin: prestodb/presto
return packDateTimeWithZone(parseResult.getLong(INSTANT_SECONDS) * 1000 + parseResult.getLong(MILLI_OF_SECOND), getTimeZoneKey(ZoneId.from(parseResult).getId()));
return packDateTimeWithZone(parseResult.get(MILLI_OF_DAY), getTimeZoneKey(ZoneId.from(parseResult).getId()));
代码示例来源:origin: apache/hive
zoneId = ZoneId.from(accessor);
} catch (DateTimeException e2) {
if (defaultTimeZone == null) {
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public String format(TemporalAccessor accessor) {
DateTimeZone timeZone = DateUtils.zoneIdToDateTimeZone(ZoneId.from(accessor));
DateTime dateTime = new DateTime(Instant.from(accessor).toEpochMilli(), timeZone);
return printer.print(dateTime);
}
代码示例来源:origin: com.github.seratch/java-time-backport
@Override
public ZoneId queryFrom(TemporalAccessor temporal) {
return ZoneId.from(temporal);
}
};
代码示例来源:origin: cn.vertxup/vertx-co
private static ZoneId getAdjust(final String literal) {
if (literal.endsWith("Z")) {
return ZoneId.from(ZoneOffset.UTC);
} else {
return ZoneId.systemDefault();
}
}
代码示例来源:origin: silentbalanceyh/vertx-zero
private static ZoneId getAdjust(final String literal) {
if (literal.endsWith("Z")) {
return ZoneId.from(ZoneOffset.UTC);
} else {
return ZoneId.systemDefault();
}
}
代码示例来源:origin: bazaarvoice/emodb
@Override
protected Instant parse(String input) throws Exception {
if (CharMatcher.DIGIT.matchesAllOf(input)) {
// Assume millis, but check for nanos
long millis = Long.parseLong(input);
if (millis >= 253402300800000L) { // +10000-01-01T00:00:00Z
millis = TimeUnit.NANOSECONDS.toMillis(millis);
}
return Instant.ofEpochMilli(millis);
}
try {
return ZonedDateTime.parse(input).toInstant();
} catch (DateTimeParseException e) {
TemporalAccessor ta = RFC_822_FORMAT.parse(input);
LocalDateTime dateTime = LocalDateTime.from(ta);
return ZonedDateTime.of(dateTime, ta.isSupported(ChronoField.OFFSET_SECONDS) ? ZoneId.from(ta) : ZoneOffset.UTC).toInstant();
}
}
}
代码示例来源:origin: netzwerg/paleo
private static Month toMonth(Instant instant) {
return instant.atZone(ZoneId.from(ZoneOffset.UTC)).getMonth();
}
代码示例来源:origin: org.fcrepo/modeshape-common
/**
* Creates a {@link ZonedDateTime} instance based on the given pattern in ISO 8601 format, compatible with the Joda date-time
* library.
* <p>
* Note that there is no direct correspondence between the JODA-style dates and the new JDK 8 date, especially
* when it comes to handling milliseconds.
* </p>
*
* @param iso8601 a {@link String} representing a date and/or time pattern, may not be null
* @return a {@link ZonedDateTime} instance, never {@code null}
*
* @throws java.time.format.DateTimeParseException if the given pattern cannot be parsed
*/
public static ZonedDateTime jodaParse( String iso8601 ) throws DateTimeParseException {
CheckArg.isNotNull(iso8601, "iso8601");
TemporalAccessor parse = JODA_ISO8601_FORMATTER.parse(iso8601);
LocalDate localDate = LocalDate.from(parse);
LocalTime localTime = parse.isSupported(ChronoField.HOUR_OF_DAY) ? LocalTime.from(parse) : LocalTime.MIDNIGHT;
ZoneId zoneId = parse.isSupported(ChronoField.OFFSET_SECONDS) ? ZoneId.from(parse) : UTC;
return ZonedDateTime.of(localDate, localTime, zoneId);
}
代码示例来源:origin: hibernate/hibernate-search
ZoneId zone = ZoneId.from( temporal );
ZoneOffset offset = ZoneOffset.from( temporal );
LocalDateTime ldt = LocalDateTime.from( temporal );
代码示例来源:origin: org.modeshape/modeshape-common
/**
* Creates a {@link ZonedDateTime} instance based on the given pattern in ISO 8601 format, compatible with the Joda date-time
* library.
* <p>
* Note that there is no direct correspondence between the JODA-style dates and the new JDK 8 date, especially
* when it comes to handling milliseconds.
* </p>
*
* @param iso8601 a {@link String} representing a date and/or time pattern, may not be null
* @return a {@link ZonedDateTime} instance, never {@code null}
*
* @throws java.time.format.DateTimeParseException if the given pattern cannot be parsed
*/
public static ZonedDateTime jodaParse( String iso8601 ) throws DateTimeParseException {
CheckArg.isNotNull(iso8601, "iso8601");
TemporalAccessor parse = JODA_ISO8601_FORMATTER.parse(iso8601);
LocalDate localDate = LocalDate.from(parse);
LocalTime localTime = parse.isSupported(ChronoField.HOUR_OF_DAY) ? LocalTime.from(parse) : LocalTime.MIDNIGHT;
ZoneId zoneId = parse.isSupported(ChronoField.OFFSET_SECONDS) ? ZoneId.from(parse) : UTC;
return ZonedDateTime.of(localDate, localTime, zoneId);
}
代码示例来源:origin: org.infinispan/infinispan-embedded-query
ZoneId zone = ZoneId.from( temporal );
ZoneOffset offset = ZoneOffset.from( temporal );
LocalDateTime ldt = LocalDateTime.from( temporal );
代码示例来源:origin: ModeShape/modeshape
/**
* Creates a {@link ZonedDateTime} instance based on the given pattern in ISO 8601 format, compatible with the Joda date-time
* library.
* <p>
* Note that there is no direct correspondence between the JODA-style dates and the new JDK 8 date, especially
* when it comes to handling milliseconds.
* </p>
*
* @param iso8601 a {@link String} representing a date and/or time pattern, may not be null
* @return a {@link ZonedDateTime} instance, never {@code null}
*
* @throws java.time.format.DateTimeParseException if the given pattern cannot be parsed
*/
public static ZonedDateTime jodaParse( String iso8601 ) throws DateTimeParseException {
CheckArg.isNotNull(iso8601, "iso8601");
TemporalAccessor parse = JODA_ISO8601_FORMATTER.parse(iso8601);
LocalDate localDate = LocalDate.from(parse);
LocalTime localTime = parse.isSupported(ChronoField.HOUR_OF_DAY) ? LocalTime.from(parse) : LocalTime.MIDNIGHT;
ZoneId zoneId = parse.isSupported(ChronoField.OFFSET_SECONDS) ? ZoneId.from(parse) : UTC;
return ZonedDateTime.of(localDate, localTime, zoneId);
}
代码示例来源:origin: com.github.seratch/java-time-backport
ZoneId zone = ZoneId.from(temporal);
if (temporal.isSupported(INSTANT_SECONDS)) {
try {
代码示例来源:origin: org.apache.hive/hive-common
zoneId = ZoneId.from(accessor);
} catch (DateTimeException e2) {
if (defaultTimeZone == null) {
代码示例来源:origin: io.prestosql/presto-record-decoder
return packDateTimeWithZone(parseResult.getLong(INSTANT_SECONDS) * 1000 + parseResult.getLong(MILLI_OF_SECOND), getTimeZoneKey(ZoneId.from(parseResult).getId()));
return packDateTimeWithZone(parseResult.get(MILLI_OF_DAY), getTimeZoneKey(ZoneId.from(parseResult).getId()));
代码示例来源:origin: prestosql/presto
return packDateTimeWithZone(parseResult.getLong(INSTANT_SECONDS) * 1000 + parseResult.getLong(MILLI_OF_SECOND), getTimeZoneKey(ZoneId.from(parseResult).getId()));
return packDateTimeWithZone(parseResult.get(MILLI_OF_DAY), getTimeZoneKey(ZoneId.from(parseResult).getId()));
代码示例来源:origin: com.facebook.presto/presto-record-decoder
return packDateTimeWithZone(parseResult.getLong(INSTANT_SECONDS) * 1000 + parseResult.getLong(MILLI_OF_SECOND), getTimeZoneKey(ZoneId.from(parseResult).getId()));
return packDateTimeWithZone(parseResult.get(MILLI_OF_DAY), getTimeZoneKey(ZoneId.from(parseResult).getId()));
代码示例来源:origin: com.github.seratch/java-time-backport
/**
* Obtains a zoned date-time in this chronology from another temporal object.
* <p>
* This creates a date-time in this chronology based on the specified {@code TemporalAccessor}.
* <p>
* This should obtain a {@code ZoneId} using {@link ZoneId#from(TemporalAccessor)}.
* The date-time should be obtained by obtaining an {@code Instant}.
* If that fails, the local date-time should be used.
*
* @param temporal the temporal object to convert, not null
* @return the zoned date-time in this chronology, not null
* @throws DateTimeException if unable to create the date-time
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public ChronoZonedDateTime<?> zonedDateTime(TemporalAccessor temporal) {
try {
ZoneId zone = ZoneId.from(temporal);
try {
Instant instant = Instant.from(temporal);
return zonedDateTime(instant, zone);
} catch (DateTimeException ex1) {
ChronoLocalDateTime cldt = localDateTime(temporal);
ChronoLocalDateTimeImpl cldtImpl = ensureChronoLocalDateTime(cldt);
return ChronoZonedDateTimeImpl.ofBest(cldtImpl, zone, null);
}
} catch (DateTimeException ex) {
throw new DateTimeException("Unable to obtain ChronoZonedDateTime from TemporalAccessor: " + temporal.getClass(), ex);
}
}
代码示例来源:origin: org.kie/kie-dmn-feel
public FEELFnResult<TemporalAccessor> invoke(@ParameterName( "date" ) TemporalAccessor date, @ParameterName( "time" ) TemporalAccessor time) {
if ( date == null ) {
return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "date", "cannot be null"));
}
if ( !(date instanceof LocalDate) ) {
// FEEL Spec Table 58 "date is a date or date time [...] creates a date time from the given date (ignoring any time component)" [that means ignoring any TZ from `date` parameter, too]
// I try to convert `date` to a LocalDate, if the query method returns null would signify conversion is not possible.
date = date.query(TemporalQueries.localDate());
if (date == null) {
return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "date", "must be an instance of LocalDate (or must be possible to convert to a FEEL date using built-in date(date) )"));
}
}
if ( time == null ) {
return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "time", "cannot be null"));
}
if (!(time instanceof LocalTime || (time.query(TemporalQueries.localTime()) != null && time.query(TemporalQueries.zone()) != null))) {
return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "time", "must be an instance of LocalTime or (it must contain localTime AND zone)"));
}
try {
if( date instanceof LocalDate && time instanceof LocalTime ) {
return FEELFnResult.ofResult( LocalDateTime.of( (LocalDate) date, (LocalTime) time ) );
} else if (date instanceof LocalDate && (time.query(TemporalQueries.localTime()) != null && time.query(TemporalQueries.zone()) != null)) {
return FEELFnResult.ofResult(ZonedDateTime.of((LocalDate) date, LocalTime.from(time), ZoneId.from(time)));
}
return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "cannot invoke function for the input parameters"));
} catch (DateTimeException e) {
return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "input parameters date-parsing exception", e));
}
}
我尝试理解[c代码 -> 汇编]代码 void node::Check( data & _data1, vector& _data2) { -> push ebp -> mov ebp,esp ->
我需要在当前表单(代码)的上下文中运行文本文件中的代码。其中一项要求是让代码创建新控件并将其添加到当前窗体。 例如,在Form1.cs中: using System.Windows.Forms; ..
我有此 C++ 代码并将其转换为 C# (.net Framework 4) 代码。有没有人给我一些关于 malloc、free 和 sprintf 方法的提示? int monate = ee; d
我的网络服务器代码有问题 #include #include #include #include #include #include #include int
给定以下 html 代码,将列表中的第三个元素(即“美丽”一词)以斜体显示的 CSS 代码是什么?当然,我可以给这个元素一个 id 或一个 class,但 html 代码必须保持不变。谢谢
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
我试图制作一个宏来避免重复代码和注释。 我试过这个: #define GrowOnPage(any Page, any Component) Component.Width := Page.Surfa
我正在尝试将我的旧 C++ 代码“翻译”成头条新闻所暗示的 C# 代码。问题是我是 C# 中的新手,并不是所有的东西都像 C++ 中那样。在 C++ 中这些解决方案运行良好,但在 C# 中只是不能。我
在 Windows 10 上工作,R 语言的格式化程序似乎没有在 Visual Studio Code 中完成它的工作。我试过R support for Visual Studio Code和 R-T
我正在处理一些报告(计数),我必须获取不同参数的计数。非常简单但乏味。 一个参数的示例查询: qCountsEmployee = ( "select count(*) from %s wher
最近几天我尝试从 d00m 调试网络错误。我开始用尽想法/线索,我希望其他 SO 用户拥有可能有用的宝贵经验。我希望能够提供所有相关信息,但我个人无法控制服务器环境。 整个事情始于用户注意到我们应用程
我有一个 app.js 文件,其中包含如下 dojo amd 模式代码: require(["dojo/dom", ..], function(dom){ dom.byId('someId').i
我对“-gencode”语句中的“code=sm_X”选项有点困惑。 一个例子:NVCC 编译器选项有什么作用 -gencode arch=compute_13,code=sm_13 嵌入库中? 只有
我为我的表格使用 X-editable 框架。 但是我有一些问题。 $(document).ready(function() { $('.access').editable({
我一直在通过本教程学习 flask/python http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-wo
我想将 Vim 和 EMACS 用于 CNC、G 代码和 M 代码。 Vim 或 EMACS 是否有任何语法或模式来处理这种类型的代码? 最佳答案 一些快速搜索使我找到了 this vim 和 thi
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?更新问题,使其成为 on-topic对于堆栈溢出。 7年前关闭。 Improve this
这个问题在这里已经有了答案: Enabling markdown highlighting in Vim (5 个回答) 6年前关闭。 当我在 Vim 中编辑包含 Markdown 代码的 READM
我正在 Swift3 iOS 中开发视频应用程序。基本上我必须将视频 Assets 和音频与淡入淡出效果合并为一个并将其保存到 iPhone 画廊。为此,我使用以下方法: private func d
pipeline { agent any stages { stage('Build') { steps { e
我是一名优秀的程序员,十分优秀!