本文整理汇总了Java中java.time.YearMonth.equals方法的典型用法代码示例。如果您正苦于以下问题:Java YearMonth.equals方法的具体用法?Java YearMonth.equals怎么用?Java YearMonth.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.YearMonth
的用法示例。
在下文中一共展示了YearMonth.equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isExtendedMonth
import java.time.YearMonth; //导入方法依赖的package包/类
/**
* A simple check to see if the given month is part of the extended months.
*
* @param month the month to check
* @return true if the given month is part of the extended months
* @see #setExtendedViewUnit(ViewUnit)
* @see #setExtendedUnitsBackward(int)
* @see #setExtendedUnitsForward(int)
*/
public final boolean isExtendedMonth(YearMonth month) {
if (month != null) {
YearMonth extendedStart = getExtendedStartMonth();
if ((month.equals(extendedStart) || month.isAfter(extendedStart)) && month.isBefore(getStartMonth())) {
return true;
}
YearMonth extendedEnd = getExtendedEndMonth();
if ((month.equals(extendedEnd) || month.isBefore(extendedEnd)) && month.isAfter(getEndMonth())) {
return true;
}
}
return false;
}
示例2: now
import java.time.YearMonth; //导入方法依赖的package包/类
@Test
public void now() {
YearMonth expected = YearMonth.now(Clock.systemDefaultZone());
YearMonth test = YearMonth.now();
for (int i = 0; i < 100; i++) {
if (expected.equals(test)) {
return;
}
expected = YearMonth.now(Clock.systemDefaultZone());
test = YearMonth.now();
}
assertEquals(test, expected);
}
示例3: now_ZoneId
import java.time.YearMonth; //导入方法依赖的package包/类
@Test
public void now_ZoneId() {
ZoneId zone = ZoneId.of("UTC+01:02:03");
YearMonth expected = YearMonth.now(Clock.system(zone));
YearMonth test = YearMonth.now(zone);
for (int i = 0; i < 100; i++) {
if (expected.equals(test)) {
return;
}
expected = YearMonth.now(Clock.system(zone));
test = YearMonth.now(zone);
}
assertEquals(test, expected);
}