java.time.YearMonth.equals()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中java.time.YearMonth.equals()方法的一些代码示例,展示了YearMonth.equals()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YearMonth.equals()方法的具体详情如下:
包路径:java.time.YearMonth
类名称:YearMonth
方法名:equals

YearMonth.equals介绍

[英]Checks if this year-month is equal to another year-month.

The comparison is based on the time-line position of the year-months.
[中]检查今年的月份是否等于另一年的月份。
比较是基于一年中月份的时间线位置。

代码示例

代码示例来源:origin: jfoenixadmin/JFoenix

void clearFocus() {
  LocalDate focusDate = datePicker.getValue();
  if (focusDate == null) {
    focusDate = LocalDate.now();
  }
  if (YearMonth.from(focusDate).equals(selectedYearMonth.get())) {
    goToDate(focusDate, true);
  }
}

代码示例来源:origin: com.github.lgooddatepicker/LGoodDatePicker

/**
 * isSameYearMonth, This compares two YearMonth variables to see if their values are equal.
 * Returns true if the values are equal, otherwise returns false.
 *
 * More specifically: This returns true if both values are null (an empty YearMonth). Or, this
 * returns true if both of the supplied YearMonths contain a YearMonth and represent the same
 * year and month. Otherwise this returns false.
 */
public static boolean isSameYearMonth(YearMonth first, YearMonth second) {
  // If both values are null, return true.
  if (first == null && second == null) {
    return true;
  }
  // At least one value contains a YearMonth. If the other value is null, then return false.
  if (first == null || second == null) {
    return false;
  }
  // Both values contain a YearMonth. 
  // Return true if the YearMonth are equal, otherwise return false.
  return first.equals(second);
}

代码示例来源:origin: OpenGamma/Strata

/**
 * Compares this observation to another based on the index and fixing date.
 * <p>
 * The maturity date is ignored.
 * 
 * @param obj  the other observation
 * @return true if equal
 */
@Override
public boolean equals(Object obj) {
 if (obj == this) {
  return true;
 }
 if (obj != null && obj.getClass() == this.getClass()) {
  PriceIndexObservation other = (PriceIndexObservation) obj;
  return index.equals(other.index) && fixingMonth.equals(other.fixingMonth);
 }
 return false;
}

代码示例来源:origin: stackoverflow.com

YearMonth yearMonth = startYm;
do {
  int days = 0;
  if ( startYm.equals ( stopYm ) ) { // If within the same (single) month.
    days = ( int ) ChronoUnit.DAYS.between ( start , stop );
  } else if ( yearMonth.equals ( startYm ) ) { // If on the first month of multiple months, count days.
    days = ( int ) ChronoUnit.DAYS.between ( start , startYm.plusMonths ( 1 ).atDay ( 1 ) ); //  Get first of next month, to accommodate the `between` method’s use of Half-Open logic.
  } else if ( yearMonth.isAfter ( startYm ) && yearMonth.isBefore ( stopYm ) ) { // If on the in-between months, ask for the days of that month.
    days = yearMonth.lengthOfMonth ();
  } else if ( yearMonth.equals ( stopYm ) ) {  // If on the last of multiple months.
    days = ( int ) ChronoUnit.DAYS.between ( stopYm.atDay ( 1 ).minusDays ( 1 ) , stop ); // Get last day of previous month, to accommodate the `between` method’s use of Half-Open logic.
  } else {
    System.out.println ( "ERROR - Reached impossible point." );
    // FIXME: Handle error condition.
  }
  map.put ( yearMonth , days ); // Cast long to int, auto-boxed to Integer.
  // Prep for next loop.
  yearMonth = yearMonth.plusMonths ( 1 );
} while (  ! yearMonth.isAfter ( stopYm ) );

代码示例来源:origin: com.jfoenix/jfoenix

void clearFocus() {
  LocalDate focusDate = datePicker.getValue();
  if (focusDate == null) {
    focusDate = LocalDate.now();
  }
  if (YearMonth.from(focusDate).equals(selectedYearMonth.get())) {
    goToDate(focusDate, true);
  }
}

代码示例来源:origin: OpenGamma/Strata

if (underlyingExpiryMonth != null && !underlyingExpiryMonth.equals(expiryMonth)) {
 underlying = SEPARATOR + "U" + underlyingExpiryMonth.format(YM_FORMAT);

相关文章