本文整理了Java中java.time.Period.isNegative()
方法的一些代码示例,展示了Period.isNegative()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Period.isNegative()
方法的具体详情如下:
包路径:java.time.Period
类名称:Period
方法名:isNegative
[英]Checks if any of the three units of this period are negative.
This checks whether the years, months or days units are less than zero.
[中]检查这段时间的三个单位中是否有一个是负数。
这将检查年、月或日单位是否小于零。
代码示例来源:origin: OpenGamma/Strata
@ImmutableValidator
private void validate() {
ArgChecker.isFalse(periodToStart.isNegative(), "Period to start must not be negative");
ArgChecker.isFalse(periodToEnd.isNegative(), "Period to end must not be negative");
}
代码示例来源:origin: OpenGamma/Strata
@ImmutableValidator
private void validate() {
ArgChecker.isFalse(periodToNear.isNegative(), "Period to start must not be negative");
ArgChecker.isFalse(periodToFar.isNegative(), "Period to end must not be negative");
}
代码示例来源:origin: OpenGamma/Strata
@ImmutableValidator
private void validate() {
ArgChecker.isFalse(depositPeriod.isNegative(), "Deposit Period must not be negative");
}
代码示例来源:origin: OpenGamma/Strata
@ImmutableValidator
private void validate() {
ArgChecker.isFalse(periodToStart.isNegative(), "Period to start must not be negative");
}
代码示例来源:origin: OpenGamma/Strata
@ImmutableValidator
private void validate() {
ArgChecker.isFalse(periodToStart.isNegative(), "Period to start must not be negative");
}
代码示例来源:origin: goldmansachs/jdmn
public static Duration toYearsMonthDuration(DatatypeFactory datatypeFactory, LocalDate date1, LocalDate date2) {
Period between = Period.between(date2, date1);
int years = between.getYears();
int months = between.getMonths();
if (between.isNegative()) {
years = - years;
months = - months;
}
return datatypeFactory.newDurationYearMonth(!between.isNegative(), years, months);
}
代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core
public static Duration toYearsMonthDuration(DatatypeFactory datatypeFactory, LocalDate date1, LocalDate date2) {
Period between = Period.between(date2, date1);
int years = between.getYears();
int months = between.getMonths();
if (between.isNegative()) {
years = - years;
months = - months;
}
return datatypeFactory.newDurationYearMonth(!between.isNegative(), years, months);
}
代码示例来源:origin: OpenGamma/Strata
@ImmutableValidator
private void validate() {
ArgChecker.isFalse(depositPeriod.isNegative(), "Deposit Period must not be negative");
}
代码示例来源:origin: OpenGamma/Strata
@ImmutableValidator
private void validate() {
ArgChecker.isFalse(periodToStart.isNegative(), "Period to start must not be negative");
}
代码示例来源:origin: OpenGamma/Strata
@ImmutableValidator
private void validate() {
ArgChecker.isFalse(periodToStart.isNegative(), "Period to start must not be negative");
}
代码示例来源:origin: OpenGamma/Strata
@ImmutableValidator
private void validate() {
ArgChecker.isFalse(periodToStart.isNegative(), "Period to start must not be negative");
}
代码示例来源:origin: OpenGamma/Strata
@ImmutableValidator
private void validate() {
ArgChecker.isFalse(periodToStart.isNegative(), "Period to start must not be negative");
}
代码示例来源:origin: OpenGamma/Strata
@ImmutableValidator
private void validate() {
ArgChecker.isFalse(lag.isZero() || lag.isNegative(), "Lag must be positive");
}
代码示例来源:origin: org.codehaus.groovy/groovy-datetime
/**
* Supports the unary plus operator; returns a {@link java.time.Period} with all unit values positive.
* For example, a period of "2 years, -3 months, and -4 days" would result in a period of
* "2 years, 3 months, and 4 days." No normalization is performed.
*
* @param self a Period
* @return a positive Period
* @since 2.5.0
*/
public static Period positive(final Period self) {
return !self.isNegative() ? self : self.withDays(Math.abs(self.getDays()))
.withMonths(Math.abs(self.getMonths()))
.withYears(Math.abs(self.getYears()));
}
代码示例来源:origin: org.threeten/threeten-extra
/**
* Obtains an instance of {@code LocalDateRange} from the start and a period.
* <p>
* The end date is calculated as the start plus the duration.
* The period must not be negative.
* <p>
* The constant {@code LocalDate.MIN} can be used to indicate an unbounded far-past.
* <p>
* The period must not be zero or one day when the start date is {@code LocalDate.MIN}.
*
* @param startInclusive the inclusive start date, not null
* @param period the period from the start to the end, not null
* @return the range, not null
* @throws DateTimeException if the end is before the start,
* or if the period addition cannot be made
* @throws ArithmeticException if numeric overflow occurs when adding the period
*/
public static LocalDateRange of(LocalDate startInclusive, Period period) {
Objects.requireNonNull(startInclusive, "startInclusive");
Objects.requireNonNull(period, "period");
if (period.isNegative()) {
throw new DateTimeException("Period must not be zero or negative");
}
return new LocalDateRange(startInclusive, startInclusive.plus(period));
}
代码示例来源:origin: OpenGamma/Strata
/**
* Creates a tenor.
*
* @param period the period to represent
* @param name the name
*/
private Tenor(Period period, String name) {
ArgChecker.notNull(period, "period");
ArgChecker.isFalse(period.isZero(), "Tenor period must not be zero");
ArgChecker.isFalse(period.isNegative(), "Tenor period must not be negative");
this.period = period;
this.name = name;
}
代码示例来源:origin: com.guestful.module/guestful.module.jsr310-extensions
public static ZonedInterval upTo(ZonedDateTime from, Period p) {
return p.isNegative() ? ZonedInterval.of(from.plus(p), from) : ZonedInterval.of(from, from.plus(p));
}
代码示例来源:origin: ical4j/ical4j
if (p1.isNegative() != p2.isNegative()) {
if (p1.isNegative()) {
result = Integer.MIN_VALUE;
if (p1.isNegative()) {
return -result;
代码示例来源:origin: org.mnode.ical4j/ical4j
if (p1.isNegative() != p2.isNegative()) {
if (p1.isNegative()) {
result = Integer.MIN_VALUE;
if (p1.isNegative()) {
return -result;
代码示例来源:origin: OpenGamma/Strata
ArgChecker.notNull(period, "period");
ArgChecker.isFalse(period.isZero(), "Frequency period must not be zero");
ArgChecker.isFalse(period.isNegative(), "Frequency period must not be negative");
this.period = period;
this.name = name;
内容来源于网络,如有侵权,请联系作者删除!