org.threeten.bp.Instant.from()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(222)

本文整理了Java中org.threeten.bp.Instant.from()方法的一些代码示例,展示了Instant.from()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instant.from()方法的具体详情如下:
包路径:org.threeten.bp.Instant
类名称:Instant
方法名:from

Instant.from介绍

[英]Obtains an instance of Instant 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 Instant.

The conversion extracts the ChronoField#INSTANT_SECONDSand ChronoField#NANO_OF_SECOND fields.

This method matches the signature of the functional interface TemporalQueryallowing it to be used as a query via method reference, Instant::from.
[中]从时间对象获取Instant的实例。
临时助理表示某种形式的日期和时间信息。此工厂将任意时态对象转换为Instant的实例。
转换将提取计时场的“瞬间”和“纳米”字段。
此方法匹配函数接口TemporalQueryLow的签名,通过方法引用Instant::from将其用作查询。

代码示例

代码示例来源:origin: com.github.joschi.jackson/jackson-datatype-threetenbp

@Override
  public Instant queryFrom(TemporalAccessor temporal) {
    return Instant.from(temporal);
  }
});

代码示例来源:origin: com.github.joschi.jackson/jackson-datatype-threetenbp

@Override
  public Instant apply(TemporalAccessor temporalAccessor) {
    return Instant.from(temporalAccessor);
  }
},

代码示例来源:origin: XeroAPI/Xero-Java

@Override
 public Instant apply(TemporalAccessor temporalAccessor) {
  return Instant.from(temporalAccessor);
 }
},

代码示例来源:origin: ThreeTen/threetenbp

@Override
  public Instant queryFrom(TemporalAccessor temporal) {
    return Instant.from(temporal);
  }
};

代码示例来源:origin: org.threeten/threetenbp

@Override
  public Instant queryFrom(TemporalAccessor temporal) {
    return Instant.from(temporal);
  }
};

代码示例来源:origin: mercadolibre/java-sdk

@Override
 public Instant apply(TemporalAccessor temporalAccessor) {
  return Instant.from(temporalAccessor);
 }
},

代码示例来源:origin: gengstrand/clojure-news-feed

@Override
 public Instant apply(TemporalAccessor temporalAccessor) {
  return Instant.from(temporalAccessor);
 }
},

代码示例来源:origin: com.torodb.torod.backends/common

@Override
  public ScalarInstant toValue(String value) {
    return new InstantScalarInstant(Instant.from(DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(value)));
  }
}

代码示例来源:origin: com.torodb.torod.backends/mysql

@Override
public ScalarInstant toValue(String value) {
  return new InstantScalarInstant(Instant.from(MYSQL_JSON_INSTANT.parse(value)));
}

代码示例来源:origin: com.torodb.torod.backends/common

@Override
  public ScalarInstant fromJsonValue(JsonString value) {
    return new InstantScalarInstant(Instant.from(DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(value.getString())));
  }
}

代码示例来源:origin: com.torodb.torod.backends/mysql

@Override
  public ScalarInstant fromJsonValue(JsonString value) {
    return new InstantScalarInstant(Instant.from(InstantValueToJsonConverter.MYSQL_JSON_INSTANT.parse(value.getString())));
  }
}

代码示例来源:origin: ThreeTen/threetenbp

return OffsetDateTime.of(ldt, offset);
} catch (DateTimeException ignore) {
  Instant instant = Instant.from(temporal);
  return OffsetDateTime.ofInstant(instant, offset);

代码示例来源:origin: org.threeten/threetenbp

return OffsetDateTime.of(ldt, offset);
} catch (DateTimeException ignore) {
  Instant instant = Instant.from(temporal);
  return OffsetDateTime.ofInstant(instant, offset);

代码示例来源:origin: ThreeTen/threetenbp

/**
 * 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.threeten/threetenbp

/**
 * 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.threeten/threetenbp

Instant end = Instant.from(endExclusive);
if (unit instanceof ChronoUnit) {
  ChronoUnit f = (ChronoUnit) unit;

代码示例来源:origin: ThreeTen/threetenbp

Instant end = Instant.from(endExclusive);
if (unit instanceof ChronoUnit) {
  ChronoUnit f = (ChronoUnit) unit;

代码示例来源:origin: ThreeTen/threetenbp

return chrono.zonedDateTime(Instant.from(temporal), overrideZone);

代码示例来源:origin: org.threeten/threetenbp

return chrono.zonedDateTime(Instant.from(temporal), overrideZone);

相关文章