本文整理了Java中java.time.LocalDateTime.getSecond()
方法的一些代码示例,展示了LocalDateTime.getSecond()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDateTime.getSecond()
方法的具体详情如下:
包路径:java.time.LocalDateTime
类名称:LocalDateTime
方法名:getSecond
[英]Gets the second-of-minute field.
[中]获取分钟数字段的秒数。
代码示例来源:origin: apache/hive
public int getSeconds() {
return localDateTime.getSecond();
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Returns true if both datetime are in the same year, month and day of month, hour, minute and second, false
* otherwise.
*
* @param actual the actual datetime. expected not be null
* @param other the other datetime. expected not be null
* @return true if both datetime are in the same year, month and day of month, hour, minute and second, false
* otherwise.
*/
private static boolean areEqualIgnoringNanos(LocalDateTime actual, LocalDateTime other) {
return areEqualIgnoringSeconds(actual, other) && actual.getSecond() == other.getSecond();
}
代码示例来源:origin: joel-costigliola/assertj-core
/**
* Returns true if both datetime are in the same year, month and day of month, hour, minute and second, false
* otherwise.
*
* @param actual the actual datetime. expected not be null
* @param other the other datetime. expected not be null
* @return true if both datetime are in the same year, month and day of month, hour, minute and second, false
* otherwise.
*/
private static boolean areEqualIgnoringNanos(LocalDateTime actual, LocalDateTime other) {
return areEqualIgnoringSeconds(actual, other) && actual.getSecond() == other.getSecond();
}
代码示例来源:origin: stackoverflow.com
LocalDateTime now = LocalDateTime.now();
int year = now.getYear();
int month = now.getMonthValue();
int day = now.getDayOfMonth();
int hour = now.getHour();
int minute = now.getMinute();
int second = now.getSecond();
int millis = now.get(ChronoField.MILLI_OF_SECOND); // Note: no direct getter available.
System.out.printf("%d-%02d-%02d %02d:%02d:%02d.%03d", year, month, day, hour, minute, second, millis);
代码示例来源:origin: com.fasterxml.jackson.datatype/jackson-datatype-jsr310
private final void _serializeAsArrayContents(LocalDateTime value, JsonGenerator g,
SerializerProvider provider) throws IOException
{
g.writeNumber(value.getYear());
g.writeNumber(value.getMonthValue());
g.writeNumber(value.getDayOfMonth());
g.writeNumber(value.getHour());
g.writeNumber(value.getMinute());
final int secs = value.getSecond();
final int nanos = value.getNano();
if ((secs > 0) || (nanos > 0)) {
g.writeNumber(secs);
if (nanos > 0) {
if (useNanoseconds(provider)) {
g.writeNumber(nanos);
} else {
g.writeNumber(value.get(ChronoField.MILLI_OF_SECOND));
}
}
}
}
代码示例来源:origin: jtablesaw/tablesaw
public static long getMillisecondOfDay(long packedLocalDateTime) {
LocalDateTime localDateTime = PackedLocalDateTime.asLocalDateTime(packedLocalDateTime);
long total = (long) localDateTime.get(ChronoField.MILLI_OF_SECOND);
total += localDateTime.getSecond() * 1000;
total += localDateTime.getMinute() * 60 * 1000;
total += localDateTime.getHour() * 60 * 60 * 1000;
return total;
}
代码示例来源:origin: alibaba/fastjson
LocalDateTime localDateTime = LocalDateTime.parse(text);
localDate = LocalTime.of(localDateTime.getHour(), localDateTime.getMinute(),
localDateTime.getSecond(), localDateTime.getNano());
} else {
localDate = LocalTime.parse(text);
代码示例来源:origin: rubenlagus/TelegramBots
private static String dateFormatterForLogs(LocalDateTime dateTime) {
String dateString = "[";
dateString += dateTime.getDayOfMonth() + "_";
dateString += dateTime.getMonthValue() + "_";
dateString += dateTime.getYear() + "_";
dateString += dateTime.getHour() + ":";
dateString += dateTime.getMinute() + ":";
dateString += dateTime.getSecond();
dateString += "] ";
return dateString;
}
代码示例来源:origin: jtablesaw/tablesaw
@Test
public void testGetSecond() {
LocalDateTime now = LocalDateTime.now();
assertEquals(now.getSecond(), getSecond(pack(now)));
}
代码示例来源:origin: com.alibaba/fastjson
LocalDateTime localDateTime = LocalDateTime.parse(text);
localDate = LocalTime.of(localDateTime.getHour(), localDateTime.getMinute(),
localDateTime.getSecond(), localDateTime.getNano());
} else {
localDate = LocalTime.parse(text);
代码示例来源:origin: apache/nifi
@Override
public Date unmarshal(String date) throws Exception {
final LocalDateTime now = LocalDateTime.now();
final DateTimeFormatter parser = new DateTimeFormatterBuilder().appendPattern(DEFAULT_DATE_TIME_FORMAT)
.parseDefaulting(ChronoField.YEAR, now.getYear())
.parseDefaulting(ChronoField.MONTH_OF_YEAR, now.getMonthValue())
.parseDefaulting(ChronoField.DAY_OF_MONTH, now.getDayOfMonth())
.parseDefaulting(ChronoField.HOUR_OF_DAY, now.getHour())
.parseDefaulting(ChronoField.MINUTE_OF_HOUR, now.getMinute())
.parseDefaulting(ChronoField.SECOND_OF_MINUTE, now.getSecond())
.parseDefaulting(ChronoField.MILLI_OF_SECOND, 0)
.toFormatter(Locale.US);
final LocalDateTime parsedDateTime = LocalDateTime.parse(date, parser);
return Date.from(parsedDateTime.toInstant(ZONE_ID.getRules().getOffset(now)));
}
代码示例来源:origin: SeanDragon/protools
/**
* 获取秒数
*
* @return
*/
public int getSecond() {
return this.localDateTime.getSecond();
}
代码示例来源:origin: jtablesaw/tablesaw
@Test
public void testAsLocalDateTime() {
LocalDateTime dateTime = LocalDateTime.now();
long packed = pack(dateTime.toLocalDate(), dateTime.toLocalTime());
LocalDateTime upacked = asLocalDateTime(packed);
assertEquals(dateTime.getDayOfYear(), upacked.getDayOfYear());
assertEquals(dateTime.getHour(), upacked.getHour());
assertEquals(dateTime.getMinute(), upacked.getMinute());
assertEquals(dateTime.getSecond(), upacked.getSecond());
}
代码示例来源:origin: debezium/debezium
@SuppressWarnings("deprecation")
@Test
public void shouldReturnLocalDateTimeInstanceWhenConvertingUtilTimeToLocalDateTime() {
LocalDateTime now = LocalDateTime.now();
java.util.Date date = new java.util.Date(now.getYear()-1900,now.getMonthValue()-1,now.getDayOfMonth(),
now.getHour(),now.getMinute(),now.getSecond()); // 0 nanos!
assertThat(Conversions.toLocalDateTime(date)).isEqualTo(now.withNano(0));
}
代码示例来源:origin: prestodb/presto
private final void _serializeAsArrayContents(LocalDateTime value, JsonGenerator g,
SerializerProvider provider) throws IOException
{
g.writeNumber(value.getYear());
g.writeNumber(value.getMonthValue());
g.writeNumber(value.getDayOfMonth());
g.writeNumber(value.getHour());
g.writeNumber(value.getMinute());
final int secs = value.getSecond();
final int nanos = value.getNano();
if ((secs > 0) || (nanos > 0)) {
g.writeNumber(secs);
if (nanos > 0) {
if (useNanoseconds(provider)) {
g.writeNumber(nanos);
} else {
g.writeNumber(value.get(ChronoField.MILLI_OF_SECOND));
}
}
}
}
代码示例来源:origin: alibaba/jetcache
case SECONDS:
if (60 % time == 0) {
t = t.plusSeconds(time - t.getSecond() % time);
} else {
t = t.plusSeconds(1);
代码示例来源:origin: oblac/jodd
@Test
void testSet() {
JulianDate jdt = JulianDate.of(2008, 12, 20, 10, 44, 55, 0);
JulianDate jdt2 = JulianDate.of(jdt.integer - 1, jdt.fraction);
assertEquals(jdt.toLocalDateTime().getYear(), jdt2.toLocalDateTime().getYear());
assertEquals(jdt.toLocalDateTime().getMonth(), jdt2.toLocalDateTime().getMonth());
assertEquals(jdt.toLocalDateTime().getDayOfMonth() - 1, jdt2.toLocalDateTime().getDayOfMonth());
assertEquals(jdt.toLocalDateTime().getHour(), jdt2.toLocalDateTime().getHour());
assertEquals(jdt.toLocalDateTime().getMinute(), jdt2.toLocalDateTime().getMinute());
assertEquals(jdt.toLocalDateTime().getSecond(), jdt2.toLocalDateTime().getSecond(), 0.0001);
}
代码示例来源:origin: debezium/debezium
assertThat(c3DateTime.getHour()).isEqualTo(17);
assertThat(c3DateTime.getMinute()).isEqualTo(51);
assertThat(c3DateTime.getSecond()).isEqualTo(4);
assertThat(c3DateTime.getNano()).isEqualTo((int) TimeUnit.MILLISECONDS.toNanos(780));
assertThat(io.debezium.time.Timestamp.toEpochMillis(c3DateTime, ADJUSTER)).isEqualTo(c3.getTime());
代码示例来源:origin: apache/tinkerpop
@Override
public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final O output, final LocalDateTime localDateTime) {
output.writeInt(localDateTime.getYear());
output.writeInt(localDateTime.getMonthValue());
output.writeInt(localDateTime.getDayOfMonth());
output.writeInt(localDateTime.getHour());
output.writeInt(localDateTime.getMinute());
output.writeInt(localDateTime.getSecond());
output.writeInt(localDateTime.getNano());
}
代码示例来源:origin: mulesoft/mule
private void assertDateTime(LocalDateTime localDateTime) {
assertEquals(localDateTime.getYear(), YEAR);
assertEquals(localDateTime.getMonthValue(), MONTH);
assertEquals(localDateTime.getDayOfMonth(), DAY);
assertEquals(localDateTime.getHour(), HOUR);
assertEquals(localDateTime.getMinute(), MINUTE);
assertEquals(localDateTime.getSecond(), SECOND);
}
内容来源于网络,如有侵权,请联系作者删除!