本文整理汇总了Java中java.time.OffsetDateTime.withMinute方法的典型用法代码示例。如果您正苦于以下问题:Java OffsetDateTime.withMinute方法的具体用法?Java OffsetDateTime.withMinute怎么用?Java OffsetDateTime.withMinute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.OffsetDateTime
的用法示例。
在下文中一共展示了OffsetDateTime.withMinute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: areInSameTimeFrame
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Override
public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) {
final OffsetDateTime localBase = instant1.atOffset(UTC).withSecond(0).withNano(0);
final OffsetDateTime localStart = localBase.withMinute(localBase.getMinute() - localBase.getMinute() % 30);
final Instant start = localStart.toInstant();
final Instant startOfNext = localStart.plusMinutes(30).toInstant();
return instant2.equals(start) || (instant2.isAfter(start) && instant2.isBefore(startOfNext));
}
示例2: areInSameTimeFrame
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Override
public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) {
final OffsetDateTime localBase = instant1.atOffset(UTC).withSecond(0).withNano(0);
final OffsetDateTime localStart = localBase.withMinute(localBase.getMinute() - localBase.getMinute() % 5);
final Instant start = localStart.toInstant();
final Instant startOfNext = localStart.plusMinutes(5).toInstant();
return instant2.equals(start) || (instant2.isAfter(start) && instant2.isBefore(startOfNext));
}
示例3: areInSameTimeFrame
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Override
public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) {
final OffsetDateTime localBase = instant1.atOffset(UTC).withSecond(0).withNano(0);
final OffsetDateTime localStart = localBase.withMinute(localBase.getMinute() - localBase.getMinute() % 15);
final Instant start = localStart.toInstant();
final Instant startOfNext = localStart.plusMinutes(15).toInstant();
return instant2.equals(start) || (instant2.isAfter(start) && instant2.isBefore(startOfNext));
}
示例4: test_withMinute_normal
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Test
public void test_withMinute_normal() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
OffsetDateTime test = base.withMinute(15);
assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 15, 59), OFFSET_PONE));
}
示例5: test_withMinute_noChange
import java.time.OffsetDateTime; //导入方法依赖的package包/类
@Test
public void test_withMinute_noChange() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
OffsetDateTime test = base.withMinute(30);
assertSame(test, base);
}