gpt4 book ai didi

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

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

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

ZonalOffset.getIntegralAmount介绍

[英]Total shift in integer seconds without fractional part.
[中]不含小数部分的整数秒总移位。

代码示例

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

RuleBasedTransitionModel(
  ZonalOffset stdOffset,
  List<DaylightSavingRule> rules,
  boolean create
) {
  this(
    new ZonalTransition(
      Long.MIN_VALUE,
      stdOffset.getIntegralAmount(),
      stdOffset.getIntegralAmount(),
      0),
    rules,
    create
  );
}

代码示例来源: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

@Override
public int getOffset(long date) {
  return this.tz.getOffset(
    TemporalType.MILLIS_SINCE_UNIX.translate(Long.valueOf(date))
  ).getIntegralAmount() * 1000;
}

代码示例来源: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-range

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

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

@Override
public int getRawOffset() {
  return this.tz.getStandardOffset(SystemClock.currentMoment()).getIntegralAmount() * 1000;
}

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

@Override
public java.sql.Time from(PlainTime time) {
  long millis = time.getInt(PlainTime.MILLI_OF_DAY);
  if (!WITH_SQL_UTC_CONVERSION) {
    ZonalOffset offset =
      Timezone.ofSystem().getOffset(UNIX_DATE, time);
    millis -= offset.getIntegralAmount() * 1000;
  }
  return new java.sql.Time(millis);
}

代码示例来源: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

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-core

private int getOffset(ChronoEntity<?> entity) {
  return this.tz.getStrategy().getOffset(
    entity.get(PlainDate.COMPONENT),
    entity.get(PlainTime.COMPONENT),
    this.tz
  ).getIntegralAmount();
}

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

@Override
public int getDeviation(
  Calendrical<?, ?> calendarDay,
  TZID tzid
) {
  Optional<T> unixTime = this.event.apply(calendarDay);
  if (unixTime.isPresent()) {
    UnixTime ut = unixTime.get();
    long local = ut.getPosixTime() - 2 * 365 * 86400 + Timezone.of(tzid).getOffset(ut).getIntegralAmount();
    long midnight = calendarDay.getDaysSinceEpochUTC() * 86400;
    int timeOfDay = MathUtils.safeCast(local - midnight);
    return ((timeOfDay >= 43200) ? (timeOfDay - 86400) : timeOfDay);
  } else {
    throw new ChronoException("Cannot determine start of day: No event.");
  }
}

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

@Override
public java.sql.Timestamp from(PlainTimestamp tsp) {
  long dateMillis = // local millis
    MathUtils.safeMultiply(
      tsp.getCalendarDate().get(EpochDays.UNIX),
      86400 * 1000
    );
  long timeMillis = tsp.getInt(PlainTime.MILLI_OF_DAY);
  if (!WITH_SQL_UTC_CONVERSION) {
    ZonalOffset offset =
      Timezone.ofSystem().getOffset(tsp, tsp);
    timeMillis -= offset.getIntegralAmount() * 1000;
  }
  java.sql.Timestamp ret =
    new java.sql.Timestamp(
      MathUtils.safeAdd(dateMillis, timeMillis));
  ret.setNanos(tsp.getInt(PlainTime.NANO_OF_SECOND));
  return ret;
}

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

@Override
public PlainTime translate(java.sql.Time source) {
  long millis = source.getTime(); // UTC zone
  if (!WITH_SQL_UTC_CONVERSION) {
    Moment unixTime =
      Moment.of(
        MathUtils.floorDivide(millis, 1000),
        TimeScale.POSIX);
    ZonalOffset offset = Timezone.ofSystem().getOffset(unixTime);
    millis += offset.getIntegralAmount() * 1000;
  }
  return PlainTime.midnightAtStartOfDay().with(
    PlainTime.MILLI_OF_DAY,
    MathUtils.floorModulo(millis, 86400 * 1000)
  );
}

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

@Override
public java.sql.Date from(PlainDate date) {
  int year = date.getYear();
  if ((year < 1900) || (year > 9999)) {
    throw new ChronoException(
      "SQL-Date is only defined in year range of 1900-9999.");
  }
  long millis = // localMillis
    MathUtils.safeMultiply(
      date.get(EpochDays.UNIX),
      86400 * 1000);
  if (!WITH_SQL_UTC_CONVERSION) {
    ZonalOffset offset =
      Timezone.ofSystem().getOffset(date, PlainTime.of(0));
    millis -= offset.getIntegralAmount() * 1000;
  }
  return new java.sql.Date(millis);
}

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

@Override
public PlainDate translate(java.sql.Date source) {
  long millis = source.getTime(); // UTC zone
  if (!WITH_SQL_UTC_CONVERSION) {
    Moment unixTime =
      Moment.of(
        MathUtils.floorDivide(millis, 1000),
        TimeScale.POSIX);
    ZonalOffset offset = Timezone.ofSystem().getOffset(unixTime);
    millis += offset.getIntegralAmount() * 1000;
  }
  return PlainDate.axis().getCalendarSystem().transform(
    MathUtils.floorDivide(millis, 86400 * 1000) - 2 * 365
  );
}

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

) {
  long localSeconds = ut.getPosixTime() + offset.getIntegralAmount();
  int localNanos = ut.getNanosecond() + offset.getFractionalAmount();

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

@Override
public PlainTimestamp translate(java.sql.Timestamp source) {
  long millis = source.getTime(); // UTC zone
  if (!WITH_SQL_UTC_CONVERSION) {
    Moment unixTime =
      Moment.of(
        MathUtils.floorDivide(millis, 1000),
        TimeScale.POSIX);
    ZonalOffset offset = Timezone.ofSystem().getOffset(unixTime);
    millis += offset.getIntegralAmount() * 1000;
  }
  PlainDate date =
    PlainDate.of(
      MathUtils.floorDivide(millis, 86400 * 1000),
      EpochDays.UNIX);
  PlainTime time =
    PlainTime.of(0).plus(
      MathUtils.floorModulo(millis, 86400 * 1000), 
      ClockUnit.MILLIS);
  PlainTimestamp ts = PlainTimestamp.of(date, time);
  return ts.with(PlainTime.NANO_OF_SECOND, source.getNanos());
}

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

long posixTime = localSeconds - offset.getIntegralAmount();
int posixNanos = localNanos - offset.getFractionalAmount();

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

) {
  long localSeconds = ut.getPosixTime() + offset.getIntegralAmount();
  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)
  );
}

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