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

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

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

LocalTime.toSecondOfDay介绍

[英]Extracts the time as seconds of day, from 0 to 24 * 60 * 60 - 1.
[中]以秒为单位提取时间,从0到246060-1。

代码示例

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

@Override
public boolean serialize(final JsonContext jsonContext, final LocalTime value) {
  jsonContext.writeNumber(value.toSecondOfDay());
  return true;
}

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

@Override
public void set(final PreparedStatement st, final int index, final LocalTime value, final int dbSqlType) throws SQLException {
  if (value == null) {
    st.setNull(index, dbSqlType);
    return;
  }
  if (dbSqlType == Types.VARCHAR) {
    st.setString(index, value.toString());
    return;
  }
  st.setLong(index, value.toSecondOfDay());
}

代码示例来源:origin: OpenHFT/Chronicle-Queue

public SingleChronicleQueueBuilder rollTime(@NotNull final LocalTime rollTime, final ZoneId zoneId) {
  this.rollTime = rollTime;
  this.rollTimeZone = zoneId;
  this.epoch = TimeUnit.SECONDS.toMillis(rollTime.toSecondOfDay());
  this.queueOffsetSpec = QueueOffsetSpec.ofRollTime(rollTime, zoneId);
  return this;
}

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

public static long getNanosOfDayUTC( OffsetTime value )
  {
    long secondsOfDayLocal = value.toLocalTime().toSecondOfDay();
    long secondsOffset = value.getOffset().getTotalSeconds();
    return (secondsOfDayLocal - secondsOffset) * NANOS_PER_SECOND + value.getNano();
  }
}

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

.forEach(tripUpdate -> {
  Collection<Frequency> frequencies = feed.getFrequencies(tripUpdate.getTrip().getTripId());
  int timeOffset = (tripUpdate.getTrip().hasStartTime() && !frequencies.isEmpty()) ? LocalTime.parse(tripUpdate.getTrip().getStartTime()).toSecondOfDay() : 0;
  String key = GtfsStorage.tripKey(tripUpdate.getTrip(), !frequencies.isEmpty());
  final int[] boardEdges = staticGtfs.getBoardEdgesForTrip().get(key);

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

@Test
  void shouldGetNanosOfDayUTC()
  {
    LocalTime localTime = LocalTime.of( 14, 19, 18, 123999 );
    ZoneOffset offset = ZoneOffset.ofHours( -12 );
    OffsetTime time = OffsetTime.of( localTime, offset );

    long nanosOfDayUTC = TemporalUtil.getNanosOfDayUTC( time );

    long expectedNanosOfDayUTC = Duration.ofSeconds( localTime.toSecondOfDay() )
        .minus( offset.getTotalSeconds(), SECONDS )
        .toNanos();

    assertEquals( expectedNanosOfDayUTC + localTime.getNano(), nanosOfDayUTC );
  }
}

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

return ((Instant) value).toEpochMilli();
case TIME:
  return ((LocalTime) value).toSecondOfDay();
case BINARY:
  return (byte[]) value;

代码示例来源:origin: stackoverflow.com

LocalTime time = LocalTime.parse("12:34:45");
int secondOfDay = time.toSecondOfDay();
// Save to database

代码示例来源:origin: stackoverflow.com

LocalTime lt1 = LocalTime.parse("20:15:30", DateTimeFormatter.ofPattern("HH:mm:ss"));
LocalTime lt2 = LocalTime.parse("13:50:35", DateTimeFormatter.ofPattern("HH:mm:ss"));

long t = lt1.toSecondOfDay() + lt2.toSecondOfDay();
Duration duration = Duration.ofSeconds(t);
System.out.println(formatDuration(duration));

代码示例来源:origin: stackoverflow.com

LocalTime time = LocalTime.of(8, 25);
int hourToSec = 60*60;
int seconds = time.toSecondOfDay() + hourToSec;
time = LocalTime.ofSecondOfDay(seconds);
System.out.println(time);

代码示例来源:origin: stackoverflow.com

LocalTime lt = LocalTime.parse("6:00 AM", 
        DateTimeFormatter.ofPattern("h:m a"));
System.out.println(lt.toSecondOfDay());

代码示例来源:origin: net.openhft/chronicle-queue

public SingleChronicleQueueBuilder rollTime(@NotNull final LocalTime rollTime, final ZoneId zoneId) {
  this.rollTime = rollTime;
  this.rollTimeZone = zoneId;
  this.epoch = TimeUnit.SECONDS.toMillis(rollTime.toSecondOfDay());
  this.queueOffsetSpec = QueueOffsetSpec.ofRollTime(rollTime, zoneId);
  return this;
}

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

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

代码示例来源:origin: org.jodd/jodd-db

@Override
public void set(final PreparedStatement st, final int index, final LocalTime value, final int dbSqlType) throws SQLException {
  if (value == null) {
    st.setNull(index, dbSqlType);
    return;
  }
  if (dbSqlType == Types.VARCHAR) {
    st.setString(index, value.toString());
    return;
  }
  st.setLong(index, value.toSecondOfDay());
}

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

private LocalTimeTimestampHandler(DateTimeConverterOptions options) {
  super(lt -> DateTimeUtil.getMillis(lt.toSecondOfDay(), lt.getNano()),
      LocalTimeConverter::localTimeFromMillisOfDay,
      LocalTime::toNanoOfDay,
      LocalTime::ofNanoOfDay,
      LOCAL_TIME_TEMPORAL_FIELDS, LocalTime::now);
}

代码示例来源:origin: com.github.seratch/java-time-backport

private void mergeInstantFields0(ZoneId selectedZone) {
  Instant instant = Instant.ofEpochSecond(fieldValues.remove(INSTANT_SECONDS));
  ChronoZonedDateTime<?> zdt = chrono.zonedDateTime(instant, selectedZone);
  if (date == null) {
    addObject(zdt.toLocalDate());
  } else {
    resolveMakeChanges(INSTANT_SECONDS, zdt.toLocalDate());
  }
  addFieldValue(SECOND_OF_DAY, (long) zdt.toLocalTime().toSecondOfDay());
}

代码示例来源:origin: org.neo4j/neo4j-values

public static long getNanosOfDayUTC( OffsetTime value )
  {
    long secondsOfDayLocal = value.toLocalTime().toSecondOfDay();
    long secondsOffset = value.getOffset().getTotalSeconds();
    return (secondsOfDayLocal - secondsOffset) * NANOS_PER_SECOND + value.getNano();
  }
}

代码示例来源:origin: jpmml/jpmml-evaluator

@Override
  public FieldValue evaluate(List<FieldValue> arguments){
    checkFixedArityArguments(arguments, 1);
    LocalTime instant = getRequiredArgument(arguments, 0, "input").asLocalTime();
    SecondsSinceMidnight period = new SecondsSinceMidnight(instant.toSecondOfDay());
    return FieldValueUtil.create(TypeInfos.CONTINUOUS_INTEGER, period.intValue());
  }
};

代码示例来源:origin: com.github.seratch/java-time-backport

/**
 * Returns a suitable hash code.
 *
 * @return the hash code
 */
@Override
public int hashCode() {
  int hash = ((time.toSecondOfDay() + (timeEndOfDay ? 1 : 0)) << 15) +
      (month.ordinal() << 11) + ((dom + 32) << 5) +
      ((dow == null ? 7 : dow.ordinal()) << 2) + (timeDefinition.ordinal());
  return hash ^ standardOffset.hashCode() ^
      offsetBefore.hashCode() ^ offsetAfter.hashCode();
}

代码示例来源:origin: kiegroup/optaweb-employee-rostering

public ShiftTemplateView(Integer rotationLength, ShiftTemplate shiftTemplate) {
  super(shiftTemplate);
  this.spotId = shiftTemplate.getSpot().getId();
  this.rotationEmployeeId = (shiftTemplate.getRotationEmployee() != null) ? shiftTemplate.getRotationEmployee().getId() : null;
  this.durationBetweenRotationStartAndTemplateStart = Duration
      .ofDays(shiftTemplate.getStartDayOffset()).plusSeconds(shiftTemplate
          .getStartTime().toSecondOfDay());
  this.shiftTemplateDuration = Duration
      .ofDays((shiftTemplate.getEndDayOffset() < shiftTemplate.getStartDayOffset()) ? rotationLength : 0)
      .plusDays(shiftTemplate.getEndDayOffset() - shiftTemplate.getStartDayOffset())
      .plusSeconds(shiftTemplate.getEndTime().toSecondOfDay())
      .minusSeconds(shiftTemplate.getStartTime().toSecondOfDay());
}

相关文章