gpt4 book ai didi

java.time.ZonedDateTime.getOffset()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 20:50:40 27 4
gpt4 key购买 nike

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

ZonedDateTime.getOffset介绍

[英]Gets the zone offset, such as '+01:00'.

This is the offset of the local date-time from UTC/Greenwich.
[中]获取区域偏移量,例如“+01:00”。
这是本地日期时间与UTC/格林威治时间的偏移量。

代码示例

代码示例来源:origin: neo4j/neo4j

@Override
ZoneOffset getZoneOffset()
{
  return value.getOffset();
}

代码示例来源:origin: neo4j/neo4j

@Override
OffsetTime getTimePart( Supplier<ZoneId> defaultZone )
{
  ZoneOffset currentOffset = assertValidArgument( () ->  ZonedDateTime.ofInstant( Instant.now(), defaultZone.get() ) ).getOffset();
  return OffsetTime.of( value, currentOffset );
}

代码示例来源:origin: neo4j/neo4j

@Override
OffsetTime getTimePart( Supplier<ZoneId> defaultZone )
{
  ZoneOffset currentOffset = assertValidArgument( () -> ZonedDateTime.ofInstant( Instant.now(), defaultZone.get() ) ).getOffset();
  return OffsetTime.of(value.toLocalTime(), currentOffset);
}

代码示例来源:origin: neo4j/neo4j

@Override
OffsetTime getTimePart( Supplier<ZoneId> defaultZone )
{
  ZoneOffset offset = value.getOffset();
  LocalTime localTime = value.toLocalTime();
  return OffsetTime.of( localTime, offset );
}

代码示例来源:origin: neo4j/neo4j

@Override
  protected TimeValue selectTime(
      AnyValue temporal )
  {
    if ( !(temporal instanceof TemporalValue) )
    {
      throw new InvalidValuesArgumentException( String.format( "Cannot construct time from: %s", temporal ) );
    }
    if ( temporal instanceof TimeValue &&
        timezone == null )
    {
      return (TimeValue) temporal;
    }
    TemporalValue v = (TemporalValue) temporal;
    OffsetTime time = v.getTimePart( defaultZone );
    if ( timezone != null )
    {
      ZoneOffset currentOffset = assertValidArgument( () -> ZonedDateTime.ofInstant( Instant.now(), timezone() ) ).getOffset();
      time = time.withOffsetSameInstant( currentOffset );
    }
    return time( time );
  }
};

代码示例来源:origin: neo4j/neo4j

if ( !(timezone instanceof ZoneOffset) )
    timezone = assertValidArgument( () -> ZonedDateTime.ofInstant( Instant.now(), timezone() ) ).getOffset();
if ( timezone != null )
  ZoneOffset currentOffset = assertValidArgument( () -> ZonedDateTime.ofInstant( Instant.now(), timezone() ) ).getOffset();
  if ( selectingTime && selectingTimeZone )

代码示例来源:origin: neo4j/neo4j

if ( cmp == 0 )
  ZoneOffset thisOffset = value.getOffset();
  ZoneOffset thatOffset = that.value.getOffset();

代码示例来源:origin: neo4j/neo4j

ZoneOffset currentOffset = currentDT.getOffset();
truncatedOT = truncatedOT.withOffsetSameLocal( currentOffset );

代码示例来源:origin: debezium/debezium

private void assertTimestamp(String c4) {
  // '2014-09-08 17:51:04.777'
  // MySQL container is in UTC and the test time is during summer time period
  ZonedDateTime expectedTimestamp = ZonedDateTime.ofInstant(
      LocalDateTime.parse("2014-09-08T17:51:04.780").atZone(ZoneId.of("US/Samoa")).toInstant(),
      ZoneId.systemDefault());
  ZoneId defaultZoneId = ZoneId.systemDefault();
  ZonedDateTime c4DateTime = ZonedDateTime.parse(c4, ZonedTimestamp.FORMATTER).withZoneSameInstant(defaultZoneId);
  assertThat(c4DateTime.getYear()).isEqualTo(expectedTimestamp.getYear());
  assertThat(c4DateTime.getMonth()).isEqualTo(expectedTimestamp.getMonth());
  assertThat(c4DateTime.getDayOfMonth()).isEqualTo(expectedTimestamp.getDayOfMonth());
  assertThat(c4DateTime.getHour()).isEqualTo(expectedTimestamp.getHour());
  assertThat(c4DateTime.getMinute()).isEqualTo(expectedTimestamp.getMinute());
  assertThat(c4DateTime.getSecond()).isEqualTo(expectedTimestamp.getSecond());
  assertThat(c4DateTime.getNano()).isEqualTo(expectedTimestamp.getNano());
  // We're running the connector in the same timezone as the server, so the timezone in the timestamp
  // should match our current offset ...
  LocalDateTime expectedLocalDateTime = LocalDateTime.parse("2014-09-08T17:51:04.780");
  ZoneOffset expectedOffset = defaultZoneId.getRules().getOffset(expectedLocalDateTime);
  assertThat(c4DateTime.getOffset()).isEqualTo(expectedOffset);
}

代码示例来源:origin: stackoverflow.com

import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.TextStyle;
import java.util.Locale;
import java.util.Set;

Set<String> zoneIds = ZoneId.getAvailableZoneIds();

for (String zoneId : zoneIds) {
  ZoneId zone = ZoneId.of(zoneId);
  ZonedDateTime zonedDateTime = ZonedDateTime.now(zone);

  ZoneOffset offset = zonedDateTime.getOffset();
  String longName = zone.getDisplayName(TextStyle.FULL, Locale.ENGLISH);

  System.out.println("(" + offset + ") " + zoneId + ", " + longName);
}

代码示例来源:origin: apache/tinkerpop

@Override
  protected ByteBuf writeValue(final ZonedDateTime value, final ByteBufAllocator allocator, final GraphBinaryWriter context) throws SerializationException {
    final CompositeByteBuf result = allocator.compositeBuffer(2);
    result.addComponent(true, context.writeValue(value.toLocalDateTime(), allocator, false));
    result.addComponent(true, context.writeValue(value.getOffset(), allocator, false));
    return result;
  }
}

代码示例来源:origin: org.neo4j/neo4j-values

@Override
ZoneOffset getZoneOffset()
{
  return value.getOffset();
}

代码示例来源:origin: javers/javers

private Instant initCommitDateInstant(LocalDateTime commitDate, Instant commitDateInstant) {
  if (commitDateInstant != null) {
    return commitDateInstant;
  }
  //for old records without commitDateInstant
  return commitDate.toInstant(ZonedDateTime.now().getOffset());
}

代码示例来源:origin: eclipse/hawkbit

/**
 * Get list of all time zone offsets supported.
 */
private static List<String> getAllTimeZones() {
  final List<String> lst = ZoneId.getAvailableZoneIds().stream()
      .map(id -> ZonedDateTime.now(ZoneId.of(id)).getOffset().getId().replace("Z", "+00:00")).distinct()
      .collect(Collectors.toList());
  lst.sort(null);
  return lst;
}

代码示例来源:origin: org.neo4j/neo4j-values

@Override
OffsetTime getTimePart( Supplier<ZoneId> defaultZone )
{
  ZoneOffset currentOffset = assertValidArgument( () ->  ZonedDateTime.ofInstant( Instant.now(), defaultZone.get() ) ).getOffset();
  return OffsetTime.of( value, currentOffset );
}

代码示例来源:origin: apache/jena

/** Local (query engine) timezone including DST */ 
private static Duration localTimezoneDuration() {
  ZonedDateTime zdt = ZonedDateTime.now();
  int tzDurationInSeconds = zdt.getOffset().getTotalSeconds();
  Duration dur = NodeFunctions.duration(tzDurationInSeconds);
  return dur; 
}

代码示例来源:origin: org.neo4j/neo4j-values

@Override
OffsetTime getTimePart( Supplier<ZoneId> defaultZone )
{
  ZoneOffset offset = value.getOffset();
  LocalTime localTime = value.toLocalTime();
  return OffsetTime.of( localTime, offset );
}

代码示例来源:origin: org.eclipse/yasson

@Override
protected TimeZone deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
  try {
    final ZoneId zoneId = ZoneId.of(jsonValue);
    final ZonedDateTime zonedDateTime = LocalDateTime.now().atZone(zoneId);
    return new SimpleTimeZone(zonedDateTime.getOffset().getTotalSeconds() * 1000, zoneId.getId());
  } catch (ZoneRulesException e) {
    throw new JsonbException(Messages.getMessage(MessageKeys.ZONE_PARSE_ERROR, jsonValue), e);
  }
}

代码示例来源:origin: apache/james-project

@Test
void offsetShouldBeParsed() {
  ZonedDateTime dateTime = ZonedDateTime.parse("3 Jun 2017 04:35:11 -0712", ImapDateTimeFormatter.rfc5322());
  assertThat(dateTime.getOffset()).isEqualTo(ZoneOffset.ofHoursMinutes(-7, -12));
}

代码示例来源:origin: org.apache.tinkerpop/gremlin-driver

@Override
  public ByteBuf writeValue(final ZonedDateTime value, final ByteBufAllocator allocator, final GraphBinaryWriter context) throws SerializationException {
    final CompositeByteBuf result = allocator.compositeBuffer(2);
    result.addComponent(true, context.writeValue(value.toLocalDateTime(), allocator, false));
    result.addComponent(true, context.writeValue(value.getOffset(), allocator, false));
    return result;
  }
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com