本文整理了Java中java.time.ZoneOffset.systemDefault()
方法的一些代码示例,展示了ZoneOffset.systemDefault()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneOffset.systemDefault()
方法的具体详情如下:
包路径:java.time.ZoneOffset
类名称:ZoneOffset
方法名:systemDefault
暂无
代码示例来源:origin: requery/requery
@Override
public ZonedDateTime convertToMapped(Class<? extends ZonedDateTime> type, Timestamp value) {
if (value == null) {
return null;
}
Instant instant = value.toInstant();
return ZonedDateTime.ofInstant(instant, ZoneOffset.systemDefault());
}
}
代码示例来源:origin: requery/requery
@Override
public OffsetDateTime convertToMapped(Class<? extends OffsetDateTime> type, Timestamp value) {
if (value == null) {
return null;
}
return OffsetDateTime.ofInstant(value.toInstant(), ZoneOffset.systemDefault());
}
}
代码示例来源:origin: mulesoft/mule
private void assertEquals(LocalDateTime dateTime, Date date) {
assertThat(dateTime.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli(), equalTo(date.getTime()));
}
}
代码示例来源:origin: SonarSource/sonarlint-intellij
@CheckForNull
public ZonedDateTime getLastEventPolling() {
if (lastEventPolling != null) {
return ZonedDateTime.ofInstant(Instant.ofEpochMilli(lastEventPolling), ZoneOffset.systemDefault());
}
return null;
}
代码示例来源:origin: Zlika/reproducible-build-maven-plugin
/**
* Creates ZipStripper with specified configuration.
*.
* @param zipDateTime date and time for zip archive entries.
*/
public ZipStripper(LocalDateTime zipDateTime, boolean fixZipExternalFileAttributes)
{
zipTimestamp = zipDateTime.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli();
this.fixZipExternalFileAttributes = fixZipExternalFileAttributes;
}
代码示例来源:origin: epam/DLab
@Override
public LocalDate deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
ObjectCodec oc = p.getCodec();
JsonNode node = oc.readTree(p);
if (node.get(DATE_NODE) != null) {
String dateValue = node.get(DATE_NODE).asText();
return Instant.ofEpochMilli(Long.valueOf(dateValue)).atZone(ZoneOffset.systemDefault()).toLocalDate();
} else {
return Instant.ofEpochMilli(node.asLong()).atZone(ZoneOffset.systemDefault()).toLocalDate();
}
}
}
代码示例来源:origin: SonarSource/sonarlint-eclipse
private ZonedDateTime readFromFile() {
if (!lastEventPollingPath.toFile().isFile()) {
return null;
}
try {
long millis = Long.parseLong(new String(Files.readAllBytes(lastEventPollingPath), Charset.defaultCharset()));
return ZonedDateTime.ofInstant(Instant.ofEpochMilli(millis), ZoneOffset.systemDefault());
} catch (IOException | NumberFormatException e) {
// ignore
}
return null;
}
代码示例来源:origin: UniversaBlockchain/universa
@Override
public Object deserialize(Binder binder, BiDeserializer deserializer) {
return ZonedDateTime.ofInstant(Instant.ofEpochSecond(binder.getLongOrThrow("seconds")),
ZoneOffset.systemDefault());
}
代码示例来源:origin: triplea-game/triplea
/**
* Replacement for {@code Date.toString}.
*
* @param dateTime The DateTime which should be formatted
* @return a Formatted String of the given DateTime
*/
public static String toDateString(final LocalDateTime dateTime) {
return DateTimeFormatter.ofPattern("EEE MMM dd HH:mm:ss zzz yyyy").withZone(ZoneOffset.systemDefault())
.format(dateTime);
}
}
代码示例来源:origin: com.obsidiandynamics.socketx/socketx-core
/**
* Obtains the last activity time as a {@link ZonedDateTime}.
*
* @return The last activity time.
*/
default ZonedDateTime getLastActivityZoned() {
return ZonedDateTime.ofInstant(Instant.ofEpochMilli(getLastActivityTime()), ZoneOffset.systemDefault());
}
代码示例来源:origin: epam/DLab
@Override
public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
ObjectCodec oc = p.getCodec();
JsonNode node = oc.readTree(p);
if (node.get(DATE_NODE) != null) {
String dateValue = node.get(DATE_NODE).asText();
return Instant.ofEpochMilli(Long.valueOf(dateValue)).atZone(ZoneOffset.systemDefault()).toLocalDateTime();
} else {
return Instant.ofEpochMilli(node.asLong()).atZone(ZoneOffset.systemDefault()).toLocalDateTime();
}
}
}
代码示例来源:origin: io.requery/requery
@Override
public ZonedDateTime convertToMapped(Class<? extends ZonedDateTime> type, Timestamp value) {
if (value == null) {
return null;
}
Instant instant = value.toInstant();
return ZonedDateTime.ofInstant(instant, ZoneOffset.systemDefault());
}
}
代码示例来源:origin: apache/servicemix-bundles
private static LocalDateTime convertToLocalDateTime(Object timestamp) {
if (timestamp instanceof LocalDateTime) {
return (LocalDateTime) timestamp;
}
return LocalDateTime.ofInstant(convertToInstant(timestamp), ZoneOffset.systemDefault());
}
代码示例来源:origin: org.pageseeder.bridge/pso-bridge
private static String format(LocalDateTime datetime) {
// We format using second resolutions in UTC
return datetime.atZone(ZoneOffset.systemDefault())
.withZoneSameInstant(ZoneOffset.UTC)
.truncatedTo(ChronoUnit.SECONDS)
.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)+"Z";
}
代码示例来源:origin: de.juplo/jpa-converters
@Override
public ZoneOffset getZoneOffset()
{
return ZoneOffset.systemDefault().getRules().getOffset(Instant.now());
}
}
代码示例来源:origin: io.requery/requery
@Override
public OffsetDateTime convertToMapped(Class<? extends OffsetDateTime> type, Timestamp value) {
if (value == null) {
return null;
}
return OffsetDateTime.ofInstant(value.toInstant(), ZoneOffset.systemDefault());
}
}
代码示例来源:origin: justlive1/oxygen
/**
* 获取服务器日期 无时分秒
*
* @param offset 偏移量 与当前日期的偏移
* @return 服务器日期
*/
@Mapping("/localDate")
public Resp localDate(@Param(value = "offset", defaultValue = "0") Integer offset) {
return Resp.success(
LocalDate.now().plusDays(offset).atStartOfDay(ZoneOffset.systemDefault()).toInstant()
.toEpochMilli());
}
代码示例来源:origin: justlive1/oxygen
/**
* 获取服务器日期时间
*
* @param offset 偏移量 与当前日期的偏移
* @return 服务器日期时间
*/
@Mapping("/localDateTime")
public Resp localDateTime(@Param(value = "offset", defaultValue = "0") Integer offset) {
return Resp.success(
LocalDateTime.now().plusDays(offset).atZone(ZoneOffset.systemDefault()).toInstant()
.toEpochMilli());
}
代码示例来源:origin: org.ballerinalang/siddhi-core
@Override
protected Object execute(Object data) {
if (data == null) {
return ZoneOffset.systemDefault().getRules().getOffset(Instant.now()).getId();
}
return getTimeZone(data.toString());
}
代码示例来源:origin: org.ballerinalang/siddhi-core
private String getTimeZone(StreamEvent streamEvent) {
String timeZone;
if (streamEvent.getType() == ComplexEvent.Type.CURRENT) {
timeZone = timeZoneExpressionExecutor.execute(streamEvent).toString();
} else {
// TIMER event has arrived.
timeZone = ZoneOffset.systemDefault().getRules().getOffset(Instant.now()).getId();
}
return timeZone;
}
内容来源于网络,如有侵权,请联系作者删除!