org.threeten.bp.LocalDate.isBefore()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(174)

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

LocalDate.isBefore介绍

[英]Checks if this date is before the specified date.

This checks to see if this date represents a point on the local time-line before the other date.

LocalDate a = LocalDate.of(2012, 6, 30); 
LocalDate b = LocalDate.of(2012, 7, 1); 
a.isBefore(b) == true 
a.isBefore(a) == false 
b.isBefore(a) == false

This method only considers the position of the two dates on the local time-line. It does not take into account the chronology, or calendar system. This is different from the comparison in #compareTo(ChronoLocalDate), but is the same approach as #DATE_COMPARATOR.
[中]检查此日期是否早于指定日期。
这将检查此日期是否表示其他日期之前的本地时间线上的某个点。

LocalDate a = LocalDate.of(2012, 6, 30); 
LocalDate b = LocalDate.of(2012, 7, 1); 
a.isBefore(b) == true 
a.isBefore(a) == false 
b.isBefore(a) == false

此方法仅考虑两个日期在本地时间线上的位置。它不考虑年表或日历系统。这与#compareTo(ChronoLocalDate)中的比较不同,但与#DATE_COMPARATOR的方法相同。

代码示例

代码示例来源:origin: prolificinteractive/material-calendarview

/**
 * Determine if this day is before the given instance
 *
 * @param other the other day to test
 * @return true if this is before other, false if equal or after
 */
public boolean isBefore(@NonNull final CalendarDay other) {
 return date.isBefore(other.getDate());
}

代码示例来源:origin: prolificinteractive/material-calendarview

/**
 * Clear the previous selection, select the range of days from first to last, and finally
 * invalidate. First day should be before last day, otherwise the selection won't happen.
 *
 * @param first The first day of the range.
 * @param last The last day in the range.
 * @see CalendarPagerAdapter#setDateSelected(CalendarDay, boolean)
 */
public void selectRange(final CalendarDay first, final CalendarDay last) {
 selectedDates.clear();
 // Copy to start from the first day and increment
 LocalDate temp = LocalDate.of(first.getYear(), first.getMonth(), first.getDay());
 // for comparison
 final LocalDate end = last.getDate();
 while( temp.isBefore(end) || temp.equals(end) ) {
  selectedDates.add(CalendarDay.from(temp));
  temp = temp.plusDays(1);
 }
 invalidateSelectedDates();
}

代码示例来源:origin: ThreeTen/threetenbp

/**
 * Constructs a {@code JapaneseDate}. This constructor does NOT validate the given parameters,
 * and {@code era} and {@code year} must agree with {@code isoDate}.
 *
 * @param era  the era, validated not null
 * @param year  the year-of-era, validated
 * @param isoDate  the standard local date, validated not null
 */
JapaneseDate(JapaneseEra era, int year, LocalDate isoDate) {
  if (isoDate.isBefore(MIN_DATE)) {
    throw new DateTimeException("Minimum supported date is January 1st Meiji 6");
  }
  this.era = era;
  this.yearOfEra = year;
  this.isoDate = isoDate;
}

代码示例来源:origin: org.threeten/threetenbp

/**
 * Constructs a {@code JapaneseDate}. This constructor does NOT validate the given parameters,
 * and {@code era} and {@code year} must agree with {@code isoDate}.
 *
 * @param era  the era, validated not null
 * @param year  the year-of-era, validated
 * @param isoDate  the standard local date, validated not null
 */
JapaneseDate(JapaneseEra era, int year, LocalDate isoDate) {
  if (isoDate.isBefore(MIN_DATE)) {
    throw new DateTimeException("Minimum supported date is January 1st Meiji 6");
  }
  this.era = era;
  this.yearOfEra = year;
  this.isoDate = isoDate;
}

代码示例来源:origin: org.threeten/threetenbp

/**
 * Obtains an instance of {@code JapaneseEra} from a date.
 *
 * @param date  the date, not null
 * @return the Era singleton, never null
 */
static JapaneseEra from(LocalDate date) {
  if (date.isBefore(MEIJI.since)) {
    throw new DateTimeException("Date too early: " + date);
  }
  JapaneseEra[] known = KNOWN_ERAS.get();
  for (int i = known.length - 1; i >= 0; i--) {
    JapaneseEra era = known[i];
    if (date.compareTo(era.since) >= 0) {
      return era;
    }
  }
  return null;
}

代码示例来源:origin: ThreeTen/threetenbp

/**
 * Obtains an instance of {@code JapaneseEra} from a date.
 *
 * @param date  the date, not null
 * @return the Era singleton, never null
 */
static JapaneseEra from(LocalDate date) {
  if (date.isBefore(MEIJI.since)) {
    throw new DateTimeException("Date too early: " + date);
  }
  JapaneseEra[] known = KNOWN_ERAS.get();
  for (int i = known.length - 1; i >= 0; i--) {
    JapaneseEra era = known[i];
    if (date.compareTo(era.since) >= 0) {
      return era;
    }
  }
  return null;
}

代码示例来源:origin: ThreeTen/threetenbp

/**
 * Creates an instance from an ISO date.
 *
 * @param isoDate  the standard local date, validated not null
 */
JapaneseDate(LocalDate isoDate) {
  if (isoDate.isBefore(MIN_DATE)) {
    throw new DateTimeException("Minimum supported date is January 1st Meiji 6");
  }
  this.era = JapaneseEra.from(isoDate);
  int yearOffset = this.era.startDate().getYear() - 1;
  this.yearOfEra = isoDate.getYear() - yearOffset;
  this.isoDate = isoDate;
}

代码示例来源:origin: org.threeten/threetenbp

/**
 * Creates an instance from an ISO date.
 *
 * @param isoDate  the standard local date, validated not null
 */
JapaneseDate(LocalDate isoDate) {
  if (isoDate.isBefore(MIN_DATE)) {
    throw new DateTimeException("Minimum supported date is January 1st Meiji 6");
  }
  this.era = JapaneseEra.from(isoDate);
  int yearOffset = this.era.startDate().getYear() - 1;
  this.yearOfEra = isoDate.getYear() - yearOffset;
  this.isoDate = isoDate;
}

代码示例来源:origin: org.threeten/threetenbp

int yearOffset = eraStartDate.getYear() - 1;
LocalDate date = LocalDate.of(yearOfEra + yearOffset, month, dayOfMonth);
if (date.isBefore(eraStartDate) || date.isAfter(eraEndDate)) {
  throw new DateTimeException("Requested date is outside bounds of era " + era);

代码示例来源:origin: ThreeTen/threetenbp

int yearOffset = eraStartDate.getYear() - 1;
LocalDate date = LocalDate.of(yearOfEra + yearOffset, month, dayOfMonth);
if (date.isBefore(eraStartDate) || date.isAfter(eraEndDate)) {
  throw new DateTimeException("Requested date is outside bounds of era " + era);

代码示例来源:origin: ThreeTen/threetenbp

if (isoDate.isBefore(eraStartDate) || isoDate.isAfter(eraEndDate)) {
  throw new DateTimeException("Requested date is outside bounds of era " + era);

代码示例来源:origin: org.threeten/threetenbp

if (isoDate.isBefore(eraStartDate) || isoDate.isAfter(eraEndDate)) {
  throw new DateTimeException("Requested date is outside bounds of era " + era);

代码示例来源:origin: org.threeten/threetenbp

if (endDate.isAfter(date) && end.time.isBefore(time)) {
  endDate = endDate.minusDays(1);
} else if (endDate.isBefore(date) && end.time.isAfter(time)) {
  endDate = endDate.plusDays(1);

代码示例来源:origin: ThreeTen/threetenbp

if (endDate.isAfter(date) && end.time.isBefore(time)) {
  endDate = endDate.minusDays(1);
} else if (endDate.isBefore(date) && end.time.isAfter(time)) {
  endDate = endDate.plusDays(1);

相关文章