gpt4 book ai didi

net.time4j.tz.ZonalOffset.getFractionalAmount()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 11:15:31 31 4
gpt4 key购买 nike

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

ZonalOffset.getFractionalAmount介绍

[英]Returns the fractional second part of this shift in nanoseconds.

Only longitudinal offsets may have fractional parts.
[中]以纳秒为单位返回此移位的小数秒部分。
只有纵向偏移可以包含小数部分。

代码示例

代码示例来源:origin: net.time4j/time4j-core

/**
 * @serialData  Checks the consistency.
 * @param       in      object input stream
 * @throws      InvalidObjectException in case of inconsistencies
 * @throws      ClassNotFoundException if class-loading fails
 */
private void readObject(ObjectInputStream in)
  throws IOException, ClassNotFoundException {
  in.defaultReadObject();
  if (this.offset.getFractionalAmount() != 0) {
    throw new InvalidObjectException("Fractional offset is invalid.");
  }
}

代码示例来源:origin: net.time4j/time4j-core

private void writeOffset(ObjectOutput out)
  throws IOException {
  ZonalOffset offset = (ZonalOffset) this.obj;
  boolean hasFraction = (offset.getFractionalAmount() != 0);
  int header = (ZONAL_OFFSET_TYPE << 4);
  if (hasFraction) {
    header |= 1;
  }
  out.writeByte(header);
  out.writeInt(offset.getIntegralAmount());
  if (hasFraction) {
    out.writeInt(offset.getFractionalAmount());
  }
}

代码示例来源:origin: net.time4j/time4j-core

private SingleOffsetTimezone(ZonalOffset offset) {
  super();
  if (offset.getFractionalAmount() == 0) {
    this.offset = offset;
  } else {
    int total = offset.getIntegralAmount();
    if (offset.getFractionalAmount() < 0) {
      total--; // corresponding to floor-divide-algorithm
    }
    this.offset = ZonalOffset.ofTotalSeconds(total);
  }
}

代码示例来源:origin: net.time4j/time4j-range

private RecurrentMomentIntervals(
  int count,
  int type,
  PlainTimestamp ref,
  ZonalOffset offset,
  Duration<?> duration
) {
  super(count, type);
  this.ref = ref;
  this.offset = offset;
  this.duration = duration;
  if (!duration.isPositive()) {
    throw new IllegalArgumentException("Duration must be positive: " + duration);
  } else if ((offset.getIntegralAmount() % 60 != 0) || (offset.getFractionalAmount() != 0)) {
    throw new IllegalArgumentException("Offset with seconds is invalid in ISO-8601: " + offset);
  }
}

代码示例来源:origin: net.time4j/time4j-core

private static boolean isNonIsoOffset(
  Timezone timezone,
  Moment context
) {
  ZonalOffset offset = timezone.getOffset(context);
  return (
    (offset.getFractionalAmount() != 0)
    || ((offset.getAbsoluteSeconds() % 60) != 0)
  );
}

代码示例来源:origin: net.time4j/time4j-range

private String getOffsetAsString() {
  if ((this.offset.getIntegralAmount() == 0) && (this.offset.getFractionalAmount() == 0)) {
    return "Z";
  }
  return this.offset.toString();
}

代码示例来源:origin: net.time4j/time4j-core

/**
 * <p>Fabrikmethode. </p>
 *
 * @param   offset  fixed shift of local time relative to UTC in seconds
 */
static SingleOffsetTimezone of(ZonalOffset offset) {
  if (
    (offset.getIntegralAmount() == 0)
    && (offset.getFractionalAmount() == 0)
  ) {
    return UTC;
  } else {
    return new SingleOffsetTimezone(offset);
  }
}

代码示例来源:origin: net.time4j/time4j-core

@Override
public V apply(Moment context) {
  ZonalOffset shift = (
    (this.offset == null)
    ? this.tz.getOffset(context)
    : this.offset);
  if (
    (this.element == PlainTime.SECOND_OF_MINUTE)
    && context.isLeapSecond()
    && (shift.getFractionalAmount() == 0)
    && ((shift.getAbsoluteSeconds() % 60) == 0)
  ) {
    return this.element.getType().cast(Integer.valueOf(60));
  }
  return PlainTimestamp.from(context, shift).get(this.element);
}

代码示例来源:origin: net.time4j/time4j-core

private ZonalDateTime(
  Moment moment,
  Timezone tz
) {
  super();
  this.zone = tz;
  ZonalOffset offset = tz.getOffset(moment);
  if (moment.isLeapSecond()) {
    if (
      (offset.getFractionalAmount() != 0)
      || ((offset.getAbsoluteSeconds() % 60) != 0)
    ) {
      throw new IllegalArgumentException(
        "Leap second can only be represented "
        + " with timezone-offset in full minutes: "
        + offset);
    }
  }
  this.moment = moment;
  this.timestamp = PlainTimestamp.from(moment, offset);
}

代码示例来源:origin: net.time4j/time4j-core

int localNanos = ut.getNanosecond() + offset.getFractionalAmount();

代码示例来源:origin: net.time4j/time4j-core

int localNanos = ut.getNanosecond() + offset.getFractionalAmount();

代码示例来源:origin: net.time4j/time4j-core

/**
 * <p>Erzeugt ein neues Datum passend zur angegebenen absoluten Zeit. </p>
 *
 * @param   ut      unix time
 * @param   offset  shift of local time relative to UTC
 * @return  new calendar date
 */
static PlainDate from(
  UnixTime ut,
  ZonalOffset offset
) {
  long localSeconds = ut.getPosixTime() + offset.getIntegralAmount();
  int localNanos = ut.getNanosecond() + offset.getFractionalAmount();
  if (localNanos < 0) {
    localSeconds--;
  } else if (localNanos >= 1000000000) {
    localSeconds++;
  }
  long mjd =
    EpochDays.MODIFIED_JULIAN_DATE.transform(
      MathUtils.floorDivide(localSeconds, 86400),
      EpochDays.UNIX);
  long packedDate = GregorianMath.toPackedDate(mjd);
  return PlainDate.of(
    GregorianMath.readYear(packedDate),
    GregorianMath.readMonth(packedDate),
    GregorianMath.readDayOfMonth(packedDate)
  );
}

代码示例来源:origin: net.time4j/time4j-core

int posixNanos = localNanos - offset.getFractionalAmount();

代码示例来源:origin: net.time4j/time4j-core

(offset.getFractionalAmount() != 0)
  || ((offset.getAbsoluteSeconds() % 60) != 0)
) {

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