java.time.LocalTime.ofSecondOfDay()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(114)

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

LocalTime.ofSecondOfDay介绍

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

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

代码示例

代码示例来源:origin: kiegroup/optaplanner

private String getTimeString(int minuteOfDay) {
  return TIME_FORMATTER.format(LocalTime.ofSecondOfDay(minuteOfDay * 60));
}

代码示例来源:origin: runelite/runelite

public void timeFloor()
{
  Duration elapsed = Duration.between(floorTime, Instant.now());
  if (firstFloorTime == null)
  {
    firstFloorTime = LocalTime.ofSecondOfDay(elapsed.getSeconds());
  }
  else if (secondFloorTime == null)
  {
    secondFloorTime = LocalTime.ofSecondOfDay(elapsed.getSeconds());
  }
  else if (olmTime == null)
  {
    olmTime = LocalTime.ofSecondOfDay(elapsed.getSeconds());
  }
  floorTime = Instant.now();
}

代码示例来源:origin: oblac/jodd

@Override
  public LocalTime get(final ResultSet rs, final int index, final int dbSqlType) throws SQLException {
    if (dbSqlType == Types.VARCHAR) {
      String string = rs.getString(index);
      if (string == null) {
        return null;
      }
      return LocalTime.parse(string);
    }

    long time = rs.getLong(index);

    if (time == 0 && rs.wasNull()) {
      return null;
    }
    return LocalTime.ofSecondOfDay(time);
  }
}

代码示例来源:origin: runelite/runelite

private String getLoginTime()
{
  if (loginTime == null)
  {
    return "Report";
  }
  Duration duration = Duration.between(loginTime, Instant.now());
  LocalTime time = LocalTime.ofSecondOfDay(duration.getSeconds());
  return time.format(DateTimeFormatter.ofPattern("HH:mm:ss"));
}

代码示例来源:origin: runelite/runelite

String getTime(boolean waveTime)
{
  final Instant now = Instant.now();
  final Duration elapsed;
  if (waveTime)
  {
    elapsed = Duration.between(prevWave, now);
  }
  else
  {
    elapsed = Duration.between(startTime, now).minusMillis(600);
  }
  return formatTime(LocalTime.ofSecondOfDay(elapsed.getSeconds()));
}

代码示例来源:origin: runelite/runelite

@Override
public String getText()
{
  if (startTime == null)
  {
    return "";
  }
  if (!stopped)
  {
    Duration elapsed = Duration.between(startTime, Instant.now());
    time = LocalTime.ofSecondOfDay(elapsed.getSeconds());
  }
  if (time.getHour() > 0)
  {
    return time.format(DateTimeFormatter.ofPattern("HH:mm"));
  }
  return time.format(DateTimeFormatter.ofPattern("mm:ss"));
}

代码示例来源:origin: kiegroup/optaplanner

private void writeTimeGrainHoursHeaders() {
  for (TimeGrain timeGrain : solution.getTimeGrainList()) {
    LocalTime startTime = LocalTime.ofSecondOfDay(timeGrain.getStartingMinuteOfDay() * 60);
    nextHeaderCell(TIME_FORMATTER.format(startTime));
  }
}

代码示例来源:origin: ben-manes/caffeine

private void status() {
 int drainStatus;
 int pendingWrites;
 local.evictionLock.lock();
 try {
  pendingWrites = local.writeBuffer().size();
  drainStatus = local.drainStatus();
 } finally {
  local.evictionLock.unlock();
 }
 LocalTime elapsedTime = LocalTime.ofSecondOfDay(stopwatch.elapsed(TimeUnit.SECONDS));
 System.out.printf("---------- %s ----------%n", elapsedTime);
 System.out.printf("Pending reads: %,d; writes: %,d%n", local.readBuffer.size(), pendingWrites);
 System.out.printf("Drain status = %s (%s)%n", STATUS[drainStatus], drainStatus);
 System.out.printf("Evictions = %,d%n", cache.stats().evictionCount());
 System.out.printf("Size = %,d (max: %,d)%n", local.data.mappingCount(), operation.maxEntries);
 System.out.printf("Lock = [%s%n", StringUtils.substringAfter(
   local.evictionLock.toString(), "["));
 System.out.printf("Pending tasks = %,d%n",
   ForkJoinPool.commonPool().getQueuedSubmissionCount());
 long maxMemory = Runtime.getRuntime().maxMemory();
 long freeMemory = Runtime.getRuntime().freeMemory();
 long allocatedMemory = Runtime.getRuntime().totalMemory();
 System.out.printf("Max Memory = %,d bytes%n", maxMemory);
 System.out.printf("Free Memory = %,d bytes%n", freeMemory);
 System.out.printf("Allocated Memory = %,d bytes%n", allocatedMemory);
 System.out.println();
}

代码示例来源:origin: kiegroup/optaplanner

private void writeDays() {
  nextSheet("Days", 1, 1, false);
  nextRow();
  nextHeaderCell("Day");
  nextHeaderCell("Start");
  nextHeaderCell("End");
  nextHeaderCell("Lunch hour start time");
  for (Day dayOfYear : solution.getDayList()) {
    nextRow();
    LocalDate date = LocalDate.ofYearDay(Year.now().getValue(), dayOfYear.getDayOfYear());
    int startMinuteOfDay = 24 * 60, endMinuteOfDay = 0;
    for (TimeGrain timeGrain : solution.getTimeGrainList()) {
      if (timeGrain.getDay().equals(dayOfYear)) {
        startMinuteOfDay = timeGrain.getStartingMinuteOfDay() < startMinuteOfDay ?
            timeGrain.getStartingMinuteOfDay() : startMinuteOfDay;
        endMinuteOfDay = timeGrain.getStartingMinuteOfDay() + TimeGrain.GRAIN_LENGTH_IN_MINUTES > endMinuteOfDay ?
            timeGrain.getStartingMinuteOfDay() + TimeGrain.GRAIN_LENGTH_IN_MINUTES : endMinuteOfDay;
      }
    }
    LocalTime startTime = LocalTime.ofSecondOfDay(startMinuteOfDay * 60);
    LocalTime endTime = LocalTime.ofSecondOfDay(endMinuteOfDay * 60);
    LocalTime lunchHourStartTime = LocalTime.ofSecondOfDay(12 * 60 * 60); // 12pm
    nextCell().setCellValue(DAY_FORMATTER.format(date));
    nextCell().setCellValue(TIME_FORMATTER.format(startTime));
    nextCell().setCellValue(TIME_FORMATTER.format(endTime));
    nextCell().setCellValue(TIME_FORMATTER.format(lunchHourStartTime));
  }
  autoSizeColumnsWithHeader();
}

代码示例来源:origin: benas/random-beans

@Override
public LocalTime getRandomValue() {
  long minSecondOfDay = min.getLong(ChronoField.SECOND_OF_DAY);
  long maxSecondOfDay = max.getLong(ChronoField.SECOND_OF_DAY);
  long randomSecondOfDay = (long) nextDouble(minSecondOfDay, maxSecondOfDay);
  return LocalTime.ofSecondOfDay(randomSecondOfDay);
}

代码示例来源:origin: rakam-io/rakam

ps.setTime(i + 1, Time.valueOf(LocalTime.ofSecondOfDay(((Number) value).intValue())), UTC_CALENDAR);
  break;
case DATE:

代码示例来源:origin: embulk/embulk

timeFromDefault = LocalTime.ofNanoOfDay(given.getLong(ChronoField.MILLI_OF_DAY) * 1000000L);
} else if (given.isSupported(ChronoField.SECOND_OF_DAY)) {
  timeFromDefault = LocalTime.ofSecondOfDay(given.getLong(ChronoField.SECOND_OF_DAY));
} else if (given.isSupported(ChronoField.MINUTE_OF_DAY)) {
  timeFromDefault = LocalTime.ofSecondOfDay(given.getLong(ChronoField.MINUTE_OF_DAY) * 60L);
} else {
  final int hourOfDay;

代码示例来源:origin: EvoSuite/evosuite

public static LocalTime ofSecondOfDay(long secondOfDay) {
  return LocalTime.ofSecondOfDay(secondOfDay);
}

代码示例来源:origin: org.optaplanner/optaplanner-examples

private String getTimeString(int minuteOfDay) {
  return TIME_FORMATTER.format(LocalTime.ofSecondOfDay(minuteOfDay * 60));
}

代码示例来源:origin: otto-de/edison-microservice

private String formatRuntime(OffsetDateTime started, OffsetDateTime stopped) {
  Duration duration = Duration.between(started, stopped);
  if (duration.toHours() >= 24) {
    return "> 24h";
  }
  LocalTime dateTime = LocalTime.ofSecondOfDay(duration.getSeconds());
  return humanReadable
      ? ofPattern("HH:mm:ss").format(dateTime)
      : ofPattern("HH:mm:ss").format(dateTime);
}

代码示例来源:origin: org.codehaus.groovy/groovy-datetime

/**
 * Returns the value of the provided field for the ZoneOffset as if the ZoneOffset's
 * hours/minutes/seconds were reckoned as a LocalTime.
 */
private static int offsetFieldValue(ZoneOffset offset, TemporalField field) {
  int offsetSeconds = offset.getTotalSeconds();
  int value = LocalTime.ofSecondOfDay(Math.abs(offsetSeconds)).get(field);
  return offsetSeconds < 0 ? value * -1 : value;
}

代码示例来源:origin: org.optaplanner/optaplanner-examples

private void writeTimeGrainHoursHeaders() {
  for (TimeGrain timeGrain : solution.getTimeGrainList()) {
    LocalTime startTime = LocalTime.ofSecondOfDay(timeGrain.getStartingMinuteOfDay() * 60);
    nextHeaderCell(TIME_FORMATTER.format(startTime));
  }
}

代码示例来源:origin: io.github.benas/random-beans

@Override
public LocalTime getRandomValue() {
  long minSecondOfDay = min.getLong(ChronoField.SECOND_OF_DAY);
  long maxSecondOfDay = max.getLong(ChronoField.SECOND_OF_DAY);
  long randomSecondOfDay = (long) nextDouble(minSecondOfDay, maxSecondOfDay);
  return LocalTime.ofSecondOfDay(randomSecondOfDay);
}

代码示例来源:origin: owlike/genson

private static LocalTime localTimeFromMillisOfDay(long millis){
    long seconds = DateTimeUtil.getSecondsFromMillis(millis);
    long nanos = DateTimeUtil.getNanosFromMillis(millis);
    return LocalTime.ofSecondOfDay(seconds).withNano((int) nanos);
  }
}

代码示例来源:origin: com.tyro.oss/random-data

public static LocalTime randomLocalTimeBetween(LocalTime start, LocalTime end) {
    return ofSecondOfDay(randomLongBetween(start.toSecondOfDay(), end.toSecondOfDay()));
  }
}

相关文章