本文整理了Java中java.time.LocalDateTime.getMinute()
方法的一些代码示例,展示了LocalDateTime.getMinute()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDateTime.getMinute()
方法的具体详情如下:
包路径:java.time.LocalDateTime
类名称:LocalDateTime
方法名:getMinute
[英]Gets the minute-of-hour field.
[中]获取小时分钟字段。
代码示例来源:origin: apache/hive
public int getMinutes() {
return localDateTime.getMinute();
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Returns true if both datetime are in the same year, month, day of month, hour and minute, 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, day of month, hour and minute, false otherwise.
*/
private static boolean areEqualIgnoringSeconds(LocalDateTime actual, LocalDateTime other) {
return areEqualIgnoringMinutes(actual, other) && actual.getMinute() == other.getMinute();
}
代码示例来源:origin: joel-costigliola/assertj-core
/**
* Returns true if both datetime are in the same year, month, day of month, hour and minute, 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, day of month, hour and minute, false otherwise.
*/
private static boolean areEqualIgnoringSeconds(LocalDateTime actual, LocalDateTime other) {
return areEqualIgnoringMinutes(actual, other) && actual.getMinute() == other.getMinute();
}
代码示例来源:origin: graphhopper/graphhopper
public static int time(LocalDateTime localDateTime) {
return time(localDateTime.getHour(), localDateTime.getMinute(), 0);
}
代码示例来源:origin: apache/usergrid
public void incrementNotificationCounter(String status){
em.incrementAggregateCounters( null,null,null,"counters.notifications."+notification.getUuid()+"."+status,1 );
LocalDateTime localDateTime = LocalDateTime.now();
StringBuilder currentDate = new StringBuilder( );
currentDate.append( "counters.notifications.aggregate."+status+"." );
currentDate.append( localDateTime.getYear()+"." );
currentDate.append( localDateTime.getMonth()+"." );
currentDate.append( localDateTime.getDayOfMonth()+"." );
currentDate.append( localDateTime.getMinute() );
em.incrementAggregateCounters( null,null,null,currentDate.toString(),1 );
}
代码示例来源:origin: runelite/runelite
sb.append(String.format("at %d:%02d", endTime.getHour(), endTime.getMinute()));
return sb.toString();
代码示例来源: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
if (text.length() == 23) {
LocalDateTime localDateTime = LocalDateTime.parse(text);
localDate = LocalTime.of(localDateTime.getHour(), localDateTime.getMinute(),
localDateTime.getSecond(), localDateTime.getNano());
} else {
代码示例来源:origin: kiegroup/optaplanner
public boolean pauseExists(Timeslot other, int pauseInMinutes) {
if (this.overlapsTime(other)) {
return false;
}
if (!this.isOnSameDayAs(other)) {
return true;
}
if (this.startsAfter(other)) {
// TODO use Duration.between(a, b).toMinutes()
return (this.getStartDateTime().getHour() * 60 + this.getStartDateTime().getMinute())
- (other.getEndDateTime().getHour() * 60 + other.getEndDateTime().getMinute()) >= pauseInMinutes;
} else {
// TODO use Duration.between(a, b).toMinutes()
return (other.getStartDateTime().getHour() * 60 + other.getStartDateTime().getMinute())
- (this.getEndDateTime().getHour() * 60 + this.getEndDateTime().getMinute()) >= pauseInMinutes;
}
}
代码示例来源: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 testGetMinute() {
LocalDateTime now = LocalDateTime.now();
assertEquals(now.getMinute(), getMinute(pack(now)));
}
代码示例来源: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: 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 MINUTES:
if (60 % time == 0) {
t = t.plusMinutes(time - t.getMinute() % time);
} else {
t = t.plusMinutes(1);
代码示例来源:origin: oblac/jodd
assertEquals(2010, foo.timestamp2.getYear());
assertEquals(1, foo.timestamp2.getHour());
assertEquals(2, foo.timestamp2.getMinute());
assertNotNull(foo.clob);
assertEquals(4, foo.clob.length());
assertEquals(2010, foo.timestamp2.getYear());
assertEquals(20, foo.timestamp2.getHour());
assertEquals(20, foo.timestamp2.getMinute());
assertEquals(4, foo.clob.length());
assertEquals("W173", foo.clob.getSubString(1, 4));
代码示例来源: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);
}
内容来源于网络,如有侵权,请联系作者删除!