本文整理汇总了Java中java.time.OffsetTime.of方法的典型用法代码示例。如果您正苦于以下问题:Java OffsetTime.of方法的具体用法?Java OffsetTime.of怎么用?Java OffsetTime.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.OffsetTime
的用法示例。
在下文中一共展示了OffsetTime.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_isBeforeIsAfterIsEqual2nanos
import java.time.OffsetTime; //导入方法依赖的package包/类
@Test
public void test_isBeforeIsAfterIsEqual2nanos() {
OffsetTime a = OffsetTime.of(11, 30, 59, 4, ZoneOffset.ofTotalSeconds(OFFSET_PONE.getTotalSeconds() + 1));
OffsetTime b = OffsetTime.of(11, 30, 59, 3, OFFSET_PONE); // a is before b due to offset
assertEquals(a.isBefore(b), true);
assertEquals(a.isEqual(b), false);
assertEquals(a.isAfter(b), false);
assertEquals(b.isBefore(a), false);
assertEquals(b.isEqual(a), false);
assertEquals(b.isAfter(a), true);
assertEquals(a.isBefore(a), false);
assertEquals(b.isBefore(b), false);
assertEquals(a.isEqual(a), true);
assertEquals(b.isEqual(b), true);
assertEquals(a.isAfter(a), false);
assertEquals(b.isAfter(b), false);
}
示例2: data_adjustInto
import java.time.OffsetTime; //导入方法依赖的package包/类
@DataProvider(name="adjustInto")
Object[][] data_adjustInto() {
return new Object[][]{
{LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.of(2012, 3, 4, 1, 1, 1, 100), LocalDateTime.of(2012, 3, 4, 23, 5, 0, 0), null},
{LocalDateTime.of(2012, Month.MARCH, 4, 0, 0), LocalDateTime.of(2012, 3, 4, 1, 1, 1, 100), LocalDateTime.of(2012, 3, 4, 0, 0), null},
{LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.MAX, LocalDateTime.of(2012, 3, 4, 23, 5), null},
{LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.MIN, LocalDateTime.of(2012, 3, 4, 23, 5), null},
{LocalDateTime.MAX, LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.MAX, null},
{LocalDateTime.MIN, LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.MIN, null},
{LocalDateTime.of(2012, 3, 4, 23, 5), OffsetDateTime.of(2210, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, ZoneOffset.UTC), null},
{LocalDateTime.of(2012, 3, 4, 23, 5), OffsetDateTime.of(2210, 2, 2, 0, 0, 0, 0, OFFSET_PONE), OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), null},
{LocalDateTime.of(2012, 3, 4, 23, 5), ZonedDateTime.of(2210, 2, 2, 0, 0, 0, 0, ZONE_PARIS), ZonedDateTime.of(2012, 3, 4, 23, 5, 0, 0, ZONE_PARIS), null},
{LocalDateTime.of(2012, 3, 4, 23, 5), LocalDate.of(2210, 2, 2), null, DateTimeException.class},
{LocalDateTime.of(2012, 3, 4, 23, 5), LocalTime.of(22, 3, 0), null, DateTimeException.class},
{LocalDateTime.of(2012, 3, 4, 23, 5), OffsetTime.of(22, 3, 0, 0, ZoneOffset.UTC), null, DateTimeException.class},
{LocalDateTime.of(2012, 3, 4, 23, 5), null, null, NullPointerException.class},
};
}
示例3: test_isBeforeIsAfterIsEqual1nanos
import java.time.OffsetTime; //导入方法依赖的package包/类
@Test
public void test_isBeforeIsAfterIsEqual1nanos() {
OffsetTime a = OffsetTime.of(11, 30, 59, 3, OFFSET_PONE);
OffsetTime b = OffsetTime.of(11, 30, 59, 4, OFFSET_PONE); // a is before b due to time
assertEquals(a.isBefore(b), true);
assertEquals(a.isEqual(b), false);
assertEquals(a.isAfter(b), false);
assertEquals(b.isBefore(a), false);
assertEquals(b.isEqual(a), false);
assertEquals(b.isAfter(a), true);
assertEquals(a.isBefore(a), false);
assertEquals(b.isBefore(b), false);
assertEquals(a.isEqual(a), true);
assertEquals(b.isEqual(b), true);
assertEquals(a.isAfter(a), false);
assertEquals(b.isAfter(b), false);
}
示例4: test_with_adjuster_OffsetTime_validOffsetIntoOverlap1
import java.time.OffsetTime; //导入方法依赖的package包/类
@Test
public void test_with_adjuster_OffsetTime_validOffsetIntoOverlap1() {
// OT has valid offset for resulting time
OffsetTime ot = OffsetTime.of(2, 30, 30, 40, OFFSET_0100); // valid offset in overlap
ZonedDateTime zdt = dateTime(2008, 10, 26, 0, 0, 0, 0, OFFSET_0200, ZONE_PARIS); // just before overlap
ZonedDateTime test = zdt.with(ot);
assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 2, 30, 30, 40));
assertEquals(test.getOffset(), OFFSET_0100);
}
示例5: test_equals_false_minute_differs
import java.time.OffsetTime; //导入方法依赖的package包/类
@Test(dataProvider="sampleTimes")
public void test_equals_false_minute_differs(int h, int m, int s, int n, ZoneOffset ignored) {
m = (m == 59 ? 58 : m);
OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE);
OffsetTime b = OffsetTime.of(h, m + 1, s, n, OFFSET_PONE);
assertEquals(a.equals(b), false);
}
示例6: test_equals_false_second_differs
import java.time.OffsetTime; //导入方法依赖的package包/类
@Test(dataProvider="sampleTimes")
public void test_equals_false_second_differs(int h, int m, int s, int n, ZoneOffset ignored) {
s = (s == 59 ? 58 : s);
OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE);
OffsetTime b = OffsetTime.of(h, m, s + 1, n, OFFSET_PONE);
assertEquals(a.equals(b), false);
}
示例7: test_with_TemporalField
import java.time.OffsetTime; //导入方法依赖的package包/类
@Test
public void test_with_TemporalField() {
OffsetTime test = OffsetTime.of(12, 30, 40, 987654321, OFFSET_PONE);
assertEquals(test.with(ChronoField.HOUR_OF_DAY, 15), OffsetTime.of(15, 30, 40, 987654321, OFFSET_PONE));
assertEquals(test.with(ChronoField.MINUTE_OF_HOUR, 50), OffsetTime.of(12, 50, 40, 987654321, OFFSET_PONE));
assertEquals(test.with(ChronoField.SECOND_OF_MINUTE, 50), OffsetTime.of(12, 30, 50, 987654321, OFFSET_PONE));
assertEquals(test.with(ChronoField.NANO_OF_SECOND, 12345), OffsetTime.of(12, 30, 40, 12345, OFFSET_PONE));
assertEquals(test.with(ChronoField.HOUR_OF_AMPM, 6), OffsetTime.of(18, 30, 40, 987654321, OFFSET_PONE));
assertEquals(test.with(ChronoField.AMPM_OF_DAY, 0), OffsetTime.of(0, 30, 40, 987654321, OFFSET_PONE));
assertEquals(test.with(ChronoField.OFFSET_SECONDS, 7205), OffsetTime.of(12, 30, 40, 987654321, ZoneOffset.ofHoursMinutesSeconds(2, 0, 5)));
}
示例8: test_compareTo_offset
import java.time.OffsetTime; //导入方法依赖的package包/类
@Test
public void test_compareTo_offset() {
OffsetTime a = OffsetTime.of(11, 30, 0, 0, OFFSET_PTWO);
OffsetTime b = OffsetTime.of(11, 30, 0, 0, OFFSET_PONE); // a is before b due to offset
assertEquals(a.compareTo(b) < 0, true);
assertEquals(b.compareTo(a) > 0, true);
assertEquals(a.compareTo(a) == 0, true);
assertEquals(b.compareTo(b) == 0, true);
assertEquals(convertInstant(a).compareTo(convertInstant(b)) < 0, true);
}
示例9: test_compareTo_time
import java.time.OffsetTime; //导入方法依赖的package包/类
@Test
public void test_compareTo_time() {
OffsetTime a = OffsetTime.of(11, 29, 0, 0, OFFSET_PONE);
OffsetTime b = OffsetTime.of(11, 30, 0, 0, OFFSET_PONE); // a is before b due to time
assertEquals(a.compareTo(b) < 0, true);
assertEquals(b.compareTo(a) > 0, true);
assertEquals(a.compareTo(a) == 0, true);
assertEquals(b.compareTo(b) == 0, true);
assertEquals(convertInstant(a).compareTo(convertInstant(b)) < 0, true);
}
示例10: test_plusNanos
import java.time.OffsetTime; //导入方法依赖的package包/类
@Test
public void test_plusNanos() {
OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
OffsetTime test = base.plusNanos(1);
assertEquals(test, OffsetTime.of(11, 30, 59, 1, OFFSET_PONE));
}
示例11: test_withMinute_normal
import java.time.OffsetTime; //导入方法依赖的package包/类
@Test
public void test_withMinute_normal() {
OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
OffsetTime test = base.withMinute(15);
assertEquals(test, OffsetTime.of(11, 15, 59, 0, OFFSET_PONE));
}
示例12: setUp
import java.time.OffsetTime; //导入方法依赖的package包/类
@BeforeMethod
public void setUp() {
TEST_11_30_59_500_PONE = OffsetTime.of(11, 30, 59, 500, OFFSET_PONE);
}
示例13: test_withMinute_noChange
import java.time.OffsetTime; //导入方法依赖的package包/类
@Test
public void test_withMinute_noChange() {
OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
OffsetTime test = base.withMinute(30);
assertEquals(test, base);
}
示例14: test_withSecond_noChange
import java.time.OffsetTime; //导入方法依赖的package包/类
@Test
public void test_withSecond_noChange() {
OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
OffsetTime test = base.withSecond(59);
assertEquals(test, base);
}
示例15: test_minusNanos_zero
import java.time.OffsetTime; //导入方法依赖的package包/类
@Test
public void test_minusNanos_zero() {
OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
OffsetTime test = base.minusNanos(0);
assertEquals(test, base);
}