本文整理了Java中java.time.OffsetDateTime.getHour()
方法的一些代码示例,展示了OffsetDateTime.getHour()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OffsetDateTime.getHour()
方法的具体详情如下:
包路径:java.time.OffsetDateTime
类名称:OffsetDateTime
方法名:getHour
[英]Gets the hour-of-day field.
[中]获取一天中的小时字段。
代码示例来源:origin: org.assertj/assertj-core
/**
* Returns true if both OffsetDateTime are in the same year, month, day of month and hour, false otherwise.
*
* @param actual the actual OffsetDateTime. expected not be null
* @param other the other OffsetDateTime. expected not be null
* @return true if both OffsetDateTime are in the same year, month, day of month and hour, false otherwise.
*/
private static boolean areEqualIgnoringMinutes(OffsetDateTime actual, OffsetDateTime other) {
return haveSameYearMonthAndDayOfMonth(actual, other) && actual.getHour() == other.getHour();
}
代码示例来源:origin: joel-costigliola/assertj-core
/**
* Returns true if both OffsetDateTime are in the same year, month, day of month and hour, false otherwise.
*
* @param actual the actual OffsetDateTime. expected not be null
* @param other the other OffsetDateTime. expected not be null
* @return true if both OffsetDateTime are in the same year, month, day of month and hour, false otherwise.
*/
private static boolean areEqualIgnoringMinutes(OffsetDateTime actual, OffsetDateTime other) {
return haveSameYearMonthAndDayOfMonth(actual, other) && actual.getHour() == other.getHour();
}
代码示例来源:origin: google/data-transfer-project
@Test
public void testTransform() {
Map<String, String> map = new HashMap<>();
map.put("dateTime", "2018-02-14T18:00:00.0000000");
map.put("timeZone", "UTC");
CalendarEventModel.CalendarEventTime time =
transformer.apply(map, new TestTransformerContext());
Assert.assertEquals(18, time.getDateTime().getHour());
Assert.assertEquals(2018, time.getDateTime().getYear());
Assert.assertEquals(14, time.getDateTime().getDayOfMonth());
}
}
代码示例来源:origin: google/data-transfer-project
@SuppressWarnings("unchecked")
@Test
public void testTransform() throws IOException {
context.setProperty(CALENDAR_ID, "123");
Map<String, Object> rawEvent = mapper.readValue(SAMPLE_CALENDAR_EVENT, Map.class);
CalendarEventModel event = transformer.apply(rawEvent, context);
Assert.assertEquals("123", event.getCalendarId());
Assert.assertEquals("Some Place", event.getLocation());
Assert.assertEquals("Test Appointment 1", event.getTitle());
Assert.assertTrue(event.getNotes().length() > 5);
Assert.assertEquals(1, event.getAttendees().size());
CalendarAttendeeModel attendee = event.getAttendees().get(0);
Assert.assertEquals("Test Test1", attendee.getDisplayName());
Assert.assertEquals("foo@foo.com", attendee.getEmail());
Assert.assertFalse(attendee.getOptional());
Assert.assertEquals(18, event.getStartTime().getDateTime().getHour());
Assert.assertEquals(0, event.getStartTime().getDateTime().getMinute());
Assert.assertEquals(18, event.getEndTime().getDateTime().getHour());
Assert.assertEquals(30, event.getEndTime().getDateTime().getMinute());
}
代码示例来源:origin: debezium/debezium
assertThat(c4DateTime.getDayOfMonth()).isEqualTo(1);
assertThat(c4DateTime.getHour()).isIn(0, 1);
assertThat(c4DateTime.getMinute()).isEqualTo(0);
assertThat(c4DateTime.getSecond()).isEqualTo(0);
代码示例来源:origin: Netflix/iceberg
static String humanHour(int hourOrdinal) {
OffsetDateTime time = EPOCH.plusHours(hourOrdinal);
return String.format("%04d-%02d-%02d-%02d",
time.getYear(), time.getMonth().getValue(), time.getDayOfMonth(), time.getHour());
}
代码示例来源:origin: avaire/avaire
/**
* Creates a new Carbon instance from the provided offset date time object.
*
* @param offsetDateTime The offset date time that the Carbon instance should be created from.
* @return a Carbon instance with the provided date and time.
*/
public static Carbon createFromOffsetDateTime(OffsetDateTime offsetDateTime) {
return Carbon.create(
offsetDateTime.getYear(),
offsetDateTime.getMonthValue(),
offsetDateTime.getDayOfMonth(),
offsetDateTime.getHour(),
offsetDateTime.getMinute(),
offsetDateTime.getSecond()
);
}
代码示例来源:origin: rocks.xmpp/xmpp-extensions-common
/**
* Creates a date value.
*
* @param date The date value.
*/
private Value(OffsetDateTime date) {
XMLGregorianCalendar xmlGregorianCalendar;
try {
xmlGregorianCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar();
xmlGregorianCalendar.setYear(date.getYear());
xmlGregorianCalendar.setMonth(date.getMonth().getValue());
xmlGregorianCalendar.setDay(date.getDayOfMonth());
xmlGregorianCalendar.setTime(date.getHour(), date.getMinute(), date.getSecond()); // date.get(ChronoField.MILLI_OF_SECOND)
xmlGregorianCalendar.setTimezone(date.getOffset().getTotalSeconds() / 60);
} catch (DatatypeConfigurationException e) {
xmlGregorianCalendar = null;
}
this.value = xmlGregorianCalendar;
}
代码示例来源:origin: hprose/hprose-java
@Override
public final void serialize(Writer writer, OffsetDateTime datetime) throws IOException {
super.serialize(writer, datetime);
OutputStream stream = writer.stream;
if (!(datetime.getOffset().equals(ZoneOffset.UTC))) {
stream.write(TagString);
ValueWriter.write(stream, datetime.toString());
}
else {
int year = datetime.getYear();
if (year > 9999 || year < 1) {
stream.write(TagString);
ValueWriter.write(stream, datetime.toString());
}
else {
ValueWriter.writeDate(stream, year, datetime.getMonthValue(), datetime.getDayOfMonth());
ValueWriter.writeTime(stream, datetime.getHour(), datetime.getMinute(), datetime.getSecond(), 0, false, true);
ValueWriter.writeNano(stream, datetime.getNano());
stream.write(TagUTC);
}
}
}
}
代码示例来源:origin: org.hprose/hprose-java
@Override
public final void serialize(Writer writer, OffsetDateTime datetime) throws IOException {
super.serialize(writer, datetime);
OutputStream stream = writer.stream;
if (!(datetime.getOffset().equals(ZoneOffset.UTC))) {
stream.write(TagString);
ValueWriter.write(stream, datetime.toString());
}
else {
int year = datetime.getYear();
if (year > 9999 || year < 1) {
stream.write(TagString);
ValueWriter.write(stream, datetime.toString());
}
else {
ValueWriter.writeDate(stream, year, datetime.getMonthValue(), datetime.getDayOfMonth());
ValueWriter.writeTime(stream, datetime.getHour(), datetime.getMinute(), datetime.getSecond(), 0, false, true);
ValueWriter.writeNano(stream, datetime.getNano());
stream.write(TagUTC);
}
}
}
}
代码示例来源:origin: ngs-doo/dsl-json
NumberConverter.write2(value.getDayOfMonth(), buf, pos + 9);
buf[pos + 11] = 'T';
NumberConverter.write2(value.getHour(), buf, pos + 12);
buf[pos + 14] = ':';
NumberConverter.write2(value.getMinute(), buf, pos + 15);
代码示例来源:origin: io.debezium/debezium-connector-mysql
assertThat(c4DateTime.getDayOfMonth()).isEqualTo(1);
assertThat(c4DateTime.getHour()).isIn(0, 1);
assertThat(c4DateTime.getMinute()).isEqualTo(0);
assertThat(c4DateTime.getSecond()).isEqualTo(0);
内容来源于网络,如有侵权,请联系作者删除!