gpt4 book ai didi

java.time.ZoneId.normalized()方法的使用及代码示例

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

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

ZoneId.normalized介绍

[英]Normalizes the time-zone ID, returning a ZoneOffset where possible.

The returns a normalized ZoneId that can be used in place of this ID. The result will have ZoneRules equivalent to those returned by this object, however the ID returned by getId() may be different.

The normalization checks if the rules of this ZoneId have a fixed offset. If they do, then the ZoneOffset equal to that offset is returned. Otherwise this is returned.
[中]标准化时区ID,尽可能返回区域偏移。
返回一个规范化的ZoneId,可以用来代替此ID。结果将具有与此对象返回的ZoneURL等效的ZoneURL,但是getId()返回的ID可能不同。
规范化检查此区域ID的规则是否有固定偏移量。如果是,则返回等于该偏移量的ZoneOffset。否则这将被返回。

代码示例

代码示例来源:origin: io.permazen/permazen-coreapi

@Override
protected String doForward(ZoneId zoneId) {
  if (zoneId == null)
    return null;
  return zoneId.normalized().getId();
}

代码示例来源:origin: org.jsimpledb/jsimpledb-coreapi

@Override
protected String doForward(ZoneId zoneId) {
  if (zoneId == null)
    return null;
  return zoneId.normalized().getId();
}

代码示例来源:origin: vt-middleware/ldaptive

@Override
public String encodeStringValue(final ZonedDateTime value)
{
 if (value.getZone().normalized().equals(ZoneOffset.UTC)) {
  return value.format(DATE_FORMAT);
 } else {
  return value.withZoneSameInstant(ZoneOffset.UTC).format(DATE_FORMAT);
 }
}

代码示例来源:origin: org.ldaptive/ldaptive

@Override
public String encodeStringValue(final ZonedDateTime value)
{
 if (value.getZone().normalized().equals(ZoneOffset.UTC)) {
  return value.format(DATE_FORMAT);
 } else {
  return value.withZoneSameInstant(ZoneOffset.UTC).format(DATE_FORMAT);
 }
}

代码示例来源:origin: ccavanaugh/jgnash

case "HK":
case "US":
  final ZonedDateTime zdtUS = lastUpdate.atZone(ZoneId.of("UTC").normalized());
  if (zdtUS.getHour() >= 21 && zdtUS.getMinute() > 25) {  // 4:25 EST for delayed online sources
    result = false;
  final ZonedDateTime zdtUK = lastUpdate.atZone(ZoneId.of("UTC").normalized());
  if (zdtUK.getHour() >= 21 && zdtUK.getMinute() > 55) {  // 4:55 EST for delayed online sources
    result = false;
  final ZonedDateTime zdtIN = lastUpdate.atZone(ZoneId.of("UTC").normalized());
  if (zdtIN.getHour() >= 20 && zdtIN.getMinute() > 55) {  // 3:55 EST for delayed online sources
    result = false;

代码示例来源:origin: com.github.seratch/java-time-backport

@Override
public boolean print(DateTimePrintContext context, StringBuilder buf) {
  ZoneId zone = context.getValue(TemporalQueries.zoneId());
  if (zone == null) {
    return false;
  }
  if (zone.normalized() instanceof ZoneOffset) {
    buf.append(zone.getId());
    return true;
  }
  Long epochSec = context.getTemporal().getLong(INSTANT_SECONDS);
  Instant instant;
  if (epochSec != null) {
    instant = Instant.ofEpochSecond(epochSec);
  } else {
    instant = Instant.ofEpochSecond(-200L * 365 * 86400);  // about 1770
  }
  TimeZone tz = TimeZone.getTimeZone(zone.getId());
  boolean daylight = zone.getRules().isDaylightSavings(instant);
  int tzstyle = (textStyle.asNormal() == TextStyle.FULL ? TimeZone.LONG : TimeZone.SHORT);
  String text = tz.getDisplayName(daylight, tzstyle, context.getLocale());
  buf.append(text);
  return true;
}

代码示例来源:origin: org.mariadb.jdbc/mariadb-java-client

ZoneId zoneId = timeZone.toZoneId().normalized();
if (zoneId instanceof ZoneOffset) {
 ZoneOffset zoneOffset = (ZoneOffset) zoneId;

代码示例来源:origin: MariaDB/mariadb-connector-j

ZoneId zoneId = timeZone.toZoneId().normalized();
if (zoneId instanceof ZoneOffset) {
 ZoneOffset zoneOffset = (ZoneOffset) zoneId;

代码示例来源:origin: org.mariadb.jdbc/mariadb-java-client

ZoneId zoneId = timeZone.toZoneId().normalized();
if (zoneId instanceof ZoneOffset) {
 ZoneOffset zoneOffset = (ZoneOffset) zoneId;

代码示例来源:origin: MariaDB/mariadb-connector-j

ZoneId zoneId = timeZone.toZoneId().normalized();
if (zoneId instanceof ZoneOffset) {
 ZoneOffset zoneOffset = (ZoneOffset) zoneId;

代码示例来源:origin: org.kie/kie-dmn-feel

{ "date and time(\"2016-07-29T05:48:23\")", LocalDateTime.of( 2016, 7, 29, 5, 48, 23, 0 ) , null},
{ "date and time( 2016, 7, 29, 5, 48, 23 )", LocalDateTime.of( 2016, 7, 29, 5, 48, 23, 0 ) , null},
{ "date and time(\"2016-07-29T05:48:23Z\")", ZonedDateTime.of(2016, 7, 29, 5, 48, 23, 0, ZoneId.of("Z").normalized()) , null},
{ "date and time( 2016, 7, 29, 5, 48, 23, -5 )", OffsetDateTime.of(2016, 7, 29, 5, 48, 23, 0, ZoneOffset.ofHours( -5 ) ) , null},
{ "date and time(\"2016-07-29T05:48:23.765-05:00\")", DateTimeFormatter.ISO_DATE_TIME.parse( "2016-07-29T05:48:23.765-05:00", ZonedDateTime::from ) , null},
{ "date and time(\"2016-07-29T05:48:23Z\") + duration( \"P1Y1M\" )", ZonedDateTime.of(2017, 8, 29, 5, 48, 23, 0, ZoneId.of("Z").normalized()) , null},
{ "date and time(\"2016-07-29T05:48:23\") + duration( \"P1Y1M\" )", LocalDateTime.of(2017, 8, 29, 5, 48, 23, 0) , null},
{ "date and time(\"2016-07-29T05:48:23Z\") + duration( \"P1DT1H1M\" )", ZonedDateTime.of(2016, 7, 30, 6, 49, 23, 0, ZoneId.of("Z").normalized()) , null},
{ "date and time(\"2016-07-29T05:48:23\") + duration( \"P1DT1H1M\" )", LocalDateTime.of(2016, 7, 30, 6, 49, 23, 0) , null},
{ "date(\"2016-07-29\") + duration( \"P3D\" )", LocalDate.of(2016, 8, 1) , null},
{ "duration( \"P3D\" ) + date(\"2016-07-29\")", LocalDate.of(2016, 8, 1) , null},
{ "duration( \"P1Y1M\" ) + date(\"2016-07-29\")", LocalDate.of(2017, 8, 29) , null},
{ "duration( \"P1Y1M\" ) + date and time(\"2016-07-29T05:48:23Z\")", ZonedDateTime.of(2017, 8, 29, 5, 48, 23, 0, ZoneId.of("Z").normalized()) , null},
{ "duration( \"P1Y1M\" ) + date and time(\"2016-07-29T05:48:23\")", LocalDateTime.of(2017, 8, 29, 5, 48, 23, 0) , null},
{ "duration( \"P1DT1H1M\" ) + date and time(\"2016-07-29T05:48:23Z\")", ZonedDateTime.of(2016, 7, 30, 6, 49, 23, 0, ZoneId.of("Z").normalized()) , null},
{ "duration( \"P1DT1H1M\" ) + date and time(\"2016-07-29T05:48:23\")", LocalDateTime.of(2016, 7, 30, 6, 49, 23, 0) , null},
{ "time(\"22:57:00\") + duration( \"PT1H1M\" )", LocalTime.of(23, 58, 0) , null},
{ "date and time(\"2016-07-29T05:48:23Z\") - duration( \"P1Y1M\" )", ZonedDateTime.of(2015, 6, 29, 5, 48, 23, 0, ZoneId.of("Z").normalized()) , null},
{ "date and time(\"2016-07-29T05:48:23\") - duration( \"P1Y1M\" )", LocalDateTime.of(2015, 6, 29, 5, 48, 23, 0) , null},
{ "date and time(\"2016-07-29T05:48:23Z\") - duration( \"P1DT1H1M\" )", ZonedDateTime.of(2016, 7, 28, 4, 47, 23, 0, ZoneId.of("Z").normalized()) , null},
{ "date and time(\"2016-07-29T05:48:23\") - duration( \"P1DT1H1M\" )", LocalDateTime.of(2016, 7, 28, 4, 47, 23, 0) , null},
{ "date(\"2016-07-29\") - duration( \"P1D\" )", LocalDate.of(2016, 7, 28) , null},

代码示例来源:origin: com.github.seratch/java-time-backport

ZoneId normalizedOffset = overrideZone.normalized();
ZoneOffset temporalOffset = temporal.query(TemporalQueries.offset());
if (normalizedOffset instanceof ZoneOffset && temporalOffset != null && normalizedOffset.equals(temporalOffset) == false) {

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