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

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

本文整理了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

  1. void clearFocus() {
  2. LocalDate focusDate = datePicker.getValue();
  3. if (focusDate == null) {
  4. focusDate = LocalDate.now();
  5. }
  6. if (YearMonth.from(focusDate).equals(selectedYearMonth.get())) {
  7. goToDate(focusDate, true);
  8. }
  9. }

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

  1. /**
  2. * isSameYearMonth, This compares two YearMonth variables to see if their values are equal.
  3. * Returns true if the values are equal, otherwise returns false.
  4. *
  5. * More specifically: This returns true if both values are null (an empty YearMonth). Or, this
  6. * returns true if both of the supplied YearMonths contain a YearMonth and represent the same
  7. * year and month. Otherwise this returns false.
  8. */
  9. public static boolean isSameYearMonth(YearMonth first, YearMonth second) {
  10. // If both values are null, return true.
  11. if (first == null && second == null) {
  12. return true;
  13. }
  14. // At least one value contains a YearMonth. If the other value is null, then return false.
  15. if (first == null || second == null) {
  16. return false;
  17. }
  18. // Both values contain a YearMonth.
  19. // Return true if the YearMonth are equal, otherwise return false.
  20. return first.equals(second);
  21. }

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

  1. /**
  2. * Compares this observation to another based on the index and fixing date.
  3. * <p>
  4. * The maturity date is ignored.
  5. *
  6. * @param obj the other observation
  7. * @return true if equal
  8. */
  9. @Override
  10. public boolean equals(Object obj) {
  11. if (obj == this) {
  12. return true;
  13. }
  14. if (obj != null && obj.getClass() == this.getClass()) {
  15. PriceIndexObservation other = (PriceIndexObservation) obj;
  16. return index.equals(other.index) && fixingMonth.equals(other.fixingMonth);
  17. }
  18. return false;
  19. }

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

  1. YearMonth yearMonth = startYm;
  2. do {
  3. int days = 0;
  4. if ( startYm.equals ( stopYm ) ) { // If within the same (single) month.
  5. days = ( int ) ChronoUnit.DAYS.between ( start , stop );
  6. } else if ( yearMonth.equals ( startYm ) ) { // If on the first month of multiple months, count days.
  7. 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.
  8. } else if ( yearMonth.isAfter ( startYm ) && yearMonth.isBefore ( stopYm ) ) { // If on the in-between months, ask for the days of that month.
  9. days = yearMonth.lengthOfMonth ();
  10. } else if ( yearMonth.equals ( stopYm ) ) { // If on the last of multiple months.
  11. 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.
  12. } else {
  13. System.out.println ( "ERROR - Reached impossible point." );
  14. // FIXME: Handle error condition.
  15. }
  16. map.put ( yearMonth , days ); // Cast long to int, auto-boxed to Integer.
  17. // Prep for next loop.
  18. yearMonth = yearMonth.plusMonths ( 1 );
  19. } while ( ! yearMonth.isAfter ( stopYm ) );

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

  1. void clearFocus() {
  2. LocalDate focusDate = datePicker.getValue();
  3. if (focusDate == null) {
  4. focusDate = LocalDate.now();
  5. }
  6. if (YearMonth.from(focusDate).equals(selectedYearMonth.get())) {
  7. goToDate(focusDate, true);
  8. }
  9. }

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

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

相关文章