当前位置: 首页>>代码示例>>Java>>正文


Java LocalTime.ofNanoOfDay方法代码示例

本文整理汇总了Java中java.time.LocalTime.ofNanoOfDay方法的典型用法代码示例。如果您正苦于以下问题:Java LocalTime.ofNanoOfDay方法的具体用法?Java LocalTime.ofNanoOfDay怎么用?Java LocalTime.ofNanoOfDay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.time.LocalTime的用法示例。


在下文中一共展示了LocalTime.ofNanoOfDay方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: plusWithOverflow

import java.time.LocalTime; //导入方法依赖的package包/类
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 += Math.floorDiv(totNanos, NANOS_PER_DAY);
    long newNoD = Math.floorMod(totNanos, NANOS_PER_DAY);
    LocalTime newTime = (newNoD == curNoD ? time : LocalTime.ofNanoOfDay(newNoD));
    return with(newDate.plus(totDays, ChronoUnit.DAYS), newTime);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:ChronoLocalDateTimeImpl.java

示例2: plusWithOverflow

import java.time.LocalTime; //导入方法依赖的package包/类
private ChronoDateTimeImpl<C> plusWithOverflow(ChronoLocalDate<C> newDate, long hours, long minutes, long seconds,
    long nanos) {

  // 9223372036854775808 long, 2147483648 int
  if ((hours | minutes | seconds | nanos) == 0) {
    return with(newDate, this.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 = this.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 ? this.time : LocalTime.ofNanoOfDay(newNoD));
  return with(newDate.plus(totDays, ChronoUnit.DAYS), newTime);
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:23,代码来源:ChronoDateTimeImpl.java

示例3: factory_ofNanoOfDay_singletons

import java.time.LocalTime; //导入方法依赖的package包/类
@Test
public void factory_ofNanoOfDay_singletons() {
    for (int i = 0; i < 24; i++) {
        LocalTime test1 = LocalTime.ofNanoOfDay(i * 1000000000L * 60L * 60L);
        LocalTime test2 = LocalTime.of(i, 0);
        assertSame(test1, test2);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:TestLocalTime.java

示例4: queryFrom

import java.time.LocalTime; //导入方法依赖的package包/类
@Override
public LocalTime queryFrom(TemporalAccessor temporal) {
    if (temporal.isSupported(NANO_OF_DAY)) {
        return LocalTime.ofNanoOfDay(temporal.getLong(NANO_OF_DAY));
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:TemporalQueries.java

示例5: format

import java.time.LocalTime; //导入方法依赖的package包/类
@Override
public boolean format(DateTimePrintContext context, StringBuilder buf) {
    ZoneId zone = context.getValue(TemporalQueries.zoneId());
    if (zone == null) {
        return false;
    }
    String zname = zone.getId();
    if (!(zone instanceof ZoneOffset)) {
        TemporalAccessor dt = context.getTemporal();
        int type = GENERIC;
        if (!isGeneric) {
            if (dt.isSupported(ChronoField.INSTANT_SECONDS)) {
                type = zone.getRules().isDaylightSavings(Instant.from(dt)) ? DST : STD;
            } else if (dt.isSupported(ChronoField.EPOCH_DAY) &&
                       dt.isSupported(ChronoField.NANO_OF_DAY)) {
                LocalDate date = LocalDate.ofEpochDay(dt.getLong(ChronoField.EPOCH_DAY));
                LocalTime time = LocalTime.ofNanoOfDay(dt.getLong(ChronoField.NANO_OF_DAY));
                LocalDateTime ldt = date.atTime(time);
                if (zone.getRules().getTransition(ldt) == null) {
                    type = zone.getRules().isDaylightSavings(ldt.atZone(zone).toInstant()) ? DST : STD;
                }
            }
        }
        String name = getDisplayName(zname, type, context.getLocale());
        if (name != null) {
            zname = name;
        }
    }
    buf.append(zname);
    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:DateTimeFormatterBuilder.java

示例6: decodeBinary

import java.time.LocalTime; //导入方法依赖的package包/类
@Override
public final LocalTime decodeBinary(final BufferReader b) {
  return LocalTime.ofNanoOfDay(b.readLong() * 1000);
}
 
开发者ID:traneio,项目名称:ndbc,代码行数:5,代码来源:LocalTimeEncoding.java

示例7: decodeBinary

import java.time.LocalTime; //导入方法依赖的package包/类
@Override
public final OffsetTime decodeBinary(final BufferReader b) {
  final LocalTime time = LocalTime.ofNanoOfDay(b.readLong() * 1000);
  final ZoneOffset zone = ZoneOffset.ofTotalSeconds(-b.readInt());
  return time.atOffset(zone);
}
 
开发者ID:traneio,项目名称:ndbc,代码行数:7,代码来源:OffsetTimeEncoding.java

示例8: factory_ofNanoOfDay

import java.time.LocalTime; //导入方法依赖的package包/类
@Test
public void factory_ofNanoOfDay() {
    LocalTime localTime = LocalTime.ofNanoOfDay(60 * 60 * 1000000000L + 17);
    check(localTime, 1, 0, 0, 17);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TCKLocalTime.java

示例9: factory_ofNanoOfDay_tooLow

import java.time.LocalTime; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void factory_ofNanoOfDay_tooLow() {
    LocalTime.ofNanoOfDay(-1);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:TCKLocalTime.java

示例10: factory_ofNanoOfDay_tooHigh

import java.time.LocalTime; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void factory_ofNanoOfDay_tooHigh() {
    LocalTime.ofNanoOfDay(24 * 60 * 60 * 1000000000L);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:TCKLocalTime.java

示例11: decodeBinary

import java.time.LocalTime; //导入方法依赖的package包/类
@Override
public LocalTime decodeBinary(int len, ByteBuf buff) {
  // micros to nanos
  return LocalTime.ofNanoOfDay(buff.readLong() * 1000);
}
 
开发者ID:vietj,项目名称:reactive-pg-client,代码行数:6,代码来源:DataType.java

示例12: getValue

import java.time.LocalTime; //导入方法依赖的package包/类
@Override
public final LocalTime getValue(long code) {
    return code == Long.MIN_VALUE ? null : LocalTime.ofNanoOfDay(code);
}
 
开发者ID:zavtech,项目名称:morpheus-core,代码行数:5,代码来源:LongCoding.java


注:本文中的java.time.LocalTime.ofNanoOfDay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。