當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。