org.threeten.bp.LocalTime.ofNanoOfDay()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(241)

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

LocalTime.ofNanoOfDay介绍

[英]Obtains an instance of LocalTime from a nanos-of-day value.

This factory may return a cached value, but applications must not rely on this.
[中]从日期值的nano获取LocalTime实例。
此工厂可能返回缓存值,但应用程序不能依赖于此。

代码示例

代码示例来源:origin: org.springframework.data/spring-data-cassandra

@Override
  public LocalTime convert(Long source) {
    return LocalTime.ofNanoOfDay(TimeUnit.MILLISECONDS.toNanos(source));
  }
}

代码示例来源:origin: org.threeten/threetenbp

private void resolveMakeChanges(TemporalField targetField, LocalTime time) {
  long nanOfDay = time.toNanoOfDay();
  Long old = fieldValues.put(ChronoField.NANO_OF_DAY, nanOfDay);
  if (old != null && old.longValue() != nanOfDay) {
    throw new DateTimeException("Conflict found: " + LocalTime.ofNanoOfDay(old) +
        " differs from " + time +
        " while resolving  " + targetField);
  }
}

代码示例来源:origin: ThreeTen/threetenbp

private void resolveMakeChanges(TemporalField targetField, LocalTime time) {
  long nanOfDay = time.toNanoOfDay();
  Long old = fieldValues.put(ChronoField.NANO_OF_DAY, nanOfDay);
  if (old != null && old.longValue() != nanOfDay) {
    throw new DateTimeException("Conflict found: " + LocalTime.ofNanoOfDay(old) +
        " differs from " + time +
        " while resolving  " + targetField);
  }
}

代码示例来源:origin: ThreeTen/threetenbp

@Override
  public LocalTime queryFrom(TemporalAccessor temporal) {
    if (temporal.isSupported(NANO_OF_DAY)) {
      return LocalTime.ofNanoOfDay(temporal.getLong(NANO_OF_DAY));
    }
    return null;
  }
};

代码示例来源:origin: org.threeten/threetenbp

@Override
  public LocalTime queryFrom(TemporalAccessor temporal) {
    if (temporal.isSupported(NANO_OF_DAY)) {
      return LocalTime.ofNanoOfDay(temporal.getLong(NANO_OF_DAY));
    }
    return null;
  }
};

代码示例来源:origin: ThreeTen/threetenbp

private ChronoLocalDateTimeImpl<D> plusWithOverflow(D newDate, long hours, long minutes, long seconds, long nanos) {
  // 9223372036854775808 long, 2147483648 int
  if ((hours | minutes | seconds | nanos) == 0) {
    return with(newDate, time);
  }
  long totDays = nanos / NANOS_PER_DAY +             //   max/24*60*60*1B
      seconds / SECONDS_PER_DAY +                //   max/24*60*60
      minutes / MINUTES_PER_DAY +                //   max/24*60
      hours / HOURS_PER_DAY;                     //   max/24
  long totNanos = nanos % NANOS_PER_DAY +                    //   max  86400000000000
      (seconds % SECONDS_PER_DAY) * NANOS_PER_SECOND +   //   max  86400000000000
      (minutes % MINUTES_PER_DAY) * NANOS_PER_MINUTE +   //   max  86400000000000
      (hours % HOURS_PER_DAY) * NANOS_PER_HOUR;          //   max  86400000000000
  long curNoD = time.toNanoOfDay();                          //   max  86400000000000
  totNanos = totNanos + curNoD;                              // total 432000000000000
  totDays += Jdk8Methods.floorDiv(totNanos, NANOS_PER_DAY);
  long newNoD = Jdk8Methods.floorMod(totNanos, NANOS_PER_DAY);
  LocalTime newTime = (newNoD == curNoD ? time : LocalTime.ofNanoOfDay(newNoD));
  return with(newDate.plus(totDays, ChronoUnit.DAYS), newTime);
}

代码示例来源:origin: org.threeten/threetenbp

private ChronoLocalDateTimeImpl<D> plusWithOverflow(D newDate, long hours, long minutes, long seconds, long nanos) {
  // 9223372036854775808 long, 2147483648 int
  if ((hours | minutes | seconds | nanos) == 0) {
    return with(newDate, time);
  }
  long totDays = nanos / NANOS_PER_DAY +             //   max/24*60*60*1B
      seconds / SECONDS_PER_DAY +                //   max/24*60*60
      minutes / MINUTES_PER_DAY +                //   max/24*60
      hours / HOURS_PER_DAY;                     //   max/24
  long totNanos = nanos % NANOS_PER_DAY +                    //   max  86400000000000
      (seconds % SECONDS_PER_DAY) * NANOS_PER_SECOND +   //   max  86400000000000
      (minutes % MINUTES_PER_DAY) * NANOS_PER_MINUTE +   //   max  86400000000000
      (hours % HOURS_PER_DAY) * NANOS_PER_HOUR;          //   max  86400000000000
  long curNoD = time.toNanoOfDay();                          //   max  86400000000000
  totNanos = totNanos + curNoD;                              // total 432000000000000
  totDays += Jdk8Methods.floorDiv(totNanos, NANOS_PER_DAY);
  long newNoD = Jdk8Methods.floorMod(totNanos, NANOS_PER_DAY);
  LocalTime newTime = (newNoD == curNoD ? time : LocalTime.ofNanoOfDay(newNoD));
  return with(newDate.plus(totDays, ChronoUnit.DAYS), newTime);
}

代码示例来源:origin: ThreeTen/threetenbp

LocalTime newTime = (newNoD == curNoD ? time : LocalTime.ofNanoOfDay(newNoD));
return with(newDate.plusDays(totDays), newTime);

代码示例来源:origin: org.threeten/threetenbp

return ofNanoOfDay((nod / dur) * dur);

代码示例来源:origin: ThreeTen/threetenbp

return ofNanoOfDay((nod / dur) * dur);

代码示例来源:origin: org.threeten/threetenbp

LocalTime newTime = (newNoD == curNoD ? time : LocalTime.ofNanoOfDay(newNoD));
return with(newDate.plusDays(totDays), newTime);

代码示例来源:origin: ThreeTen/threetenbp

switch (f) {
  case NANO_OF_SECOND: return withNano((int) newValue);
  case NANO_OF_DAY: return LocalTime.ofNanoOfDay(newValue);
  case MICRO_OF_SECOND: return withNano((int) newValue * 1000);
  case MICRO_OF_DAY: return LocalTime.ofNanoOfDay(newValue * 1000);
  case MILLI_OF_SECOND: return withNano((int) newValue * 1000000);
  case MILLI_OF_DAY: return LocalTime.ofNanoOfDay(newValue * 1000000);
  case SECOND_OF_MINUTE: return withSecond((int) newValue);
  case SECOND_OF_DAY: return plusSeconds(newValue - toSecondOfDay());

代码示例来源:origin: org.threeten/threetenbp

switch (f) {
  case NANO_OF_SECOND: return withNano((int) newValue);
  case NANO_OF_DAY: return LocalTime.ofNanoOfDay(newValue);
  case MICRO_OF_SECOND: return withNano((int) newValue * 1000);
  case MICRO_OF_DAY: return LocalTime.ofNanoOfDay(newValue * 1000);
  case MILLI_OF_SECOND: return withNano((int) newValue * 1000000);
  case MILLI_OF_DAY: return LocalTime.ofNanoOfDay(newValue * 1000000);
  case SECOND_OF_MINUTE: return withSecond((int) newValue);
  case SECOND_OF_DAY: return plusSeconds(newValue - toSecondOfDay());

代码示例来源:origin: ThreeTen/threetenbp

int excessDays = (int) Jdk8Methods.floorDiv(totalNanos, 86400000000000L);  // safe int cast
  long nod = Jdk8Methods.floorMod(totalNanos, 86400000000000L);
  addObject(LocalTime.ofNanoOfDay(nod));
  this.excessDays = Period.ofDays(excessDays);
} else {

代码示例来源:origin: org.threeten/threetenbp

int excessDays = (int) Jdk8Methods.floorDiv(totalNanos, 86400000000000L);  // safe int cast
  long nod = Jdk8Methods.floorMod(totalNanos, 86400000000000L);
  addObject(LocalTime.ofNanoOfDay(nod));
  this.excessDays = Period.ofDays(excessDays);
} else {

相关文章