本文整理汇总了Java中org.threeten.bp.ZonedDateTime.isAfter方法的典型用法代码示例。如果您正苦于以下问题:Java ZonedDateTime.isAfter方法的具体用法?Java ZonedDateTime.isAfter怎么用?Java ZonedDateTime.isAfter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.threeten.bp.ZonedDateTime
的用法示例。
在下文中一共展示了ZonedDateTime.isAfter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSchedule
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
public ZonedDateTime[] getSchedule(final ZonedDateTime startDate, final ZonedDateTime endDate) {
ArgumentChecker.notNull(startDate, "start date");
ArgumentChecker.notNull(endDate, "end date");
ArgumentChecker.isFalse(startDate.isAfter(endDate), "start date must not be after end date");
if (startDate.equals(endDate)) {
if (startDate.getDayOfMonth() == 1 && startDate.getMonth() == Month.JANUARY) {
return new ZonedDateTime[] {startDate};
}
throw new IllegalArgumentException("Start date and end date were the same but neither was the first day of the year");
}
final List<ZonedDateTime> dates = new ArrayList<>();
ZonedDateTime date = startDate.with(TemporalAdjusters.firstDayOfYear());
if (date.isBefore(startDate)) {
date = date.plusYears(1);
}
while (!date.isAfter(endDate)) {
dates.add(date);
date = date.plusYears(1);
}
return dates.toArray(EMPTY_ZONED_DATE_TIME_ARRAY);
}
示例2: toDerivative
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
* {@inheritDoc} The definition is responsible for constructing a view of the variance swap as of a particular date.
* In particular, it resolves calendars. The VarianceSwap needs an array of observations, as well as its *expected* length.
* The actual number of observations may be less than that expected at trade inception because of a market disruption event.
* ( For an example of a market disruption event, see http://cfe.cboe.com/Products/Spec_VT.aspx )
* @param valueDate Date at which valuation will occur, not null
* @param underlyingTimeSeries Time series of underlying observations, not null
* @return VarianceSwap derivative as of date
*/
@Override
public EquityVarianceSwap toDerivative(final ZonedDateTime valueDate, final DoubleTimeSeries<LocalDate> underlyingTimeSeries) {
ArgumentChecker.notNull(valueDate, "date");
ArgumentChecker.notNull(underlyingTimeSeries, "A TimeSeries of observations must be provided. If observations have not begun, please pass an empty series.");
final double timeToObsStart = TimeCalculator.getTimeBetween(valueDate, getObsStartDate());
final double timeToObsEnd = TimeCalculator.getTimeBetween(valueDate, getObsEndDate());
final double timeToSettlement = TimeCalculator.getTimeBetween(valueDate, getSettlementDate());
DoubleTimeSeries<LocalDate> realizedTS;
if (timeToObsStart > 0) {
realizedTS = ImmutableLocalDateDoubleTimeSeries.EMPTY_SERIES;
} else {
realizedTS = underlyingTimeSeries.subSeries(getObsStartDate().toLocalDate(), true, valueDate.toLocalDate(), false);
}
final double[] observations = realizedTS.valuesArrayFast();
final double[] observationWeights = {}; // TODO Case 2011-06-29 Calendar Add functionality for non-trivial weighting of observations
ZonedDateTime finalObsDate = getObsEndDate().isAfter(valueDate) ? valueDate : getObsEndDate();
int nGoodBusinessDays = finalObsDate.isAfter(getObsStartDate()) ? BusinessDayDateUtils.getWorkingDaysInclusive(getObsStartDate(), finalObsDate, getCalendar()) : 0;
final int nObsDisrupted = nGoodBusinessDays - observations.length;
ArgumentChecker.isTrue(nObsDisrupted >= 0, "Have more observations {} than good business days {}", observations.length, nGoodBusinessDays);
return new EquityVarianceSwap(timeToObsStart, timeToObsEnd, timeToSettlement, getVarStrike(), getVarNotional(), getCurrency(), getAnnualizationFactor(), getObsExpected(), nObsDisrupted,
observations, observationWeights, correctForDividends());
}
示例3: getSchedule
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
public ZonedDateTime[] getSchedule(final ZonedDateTime startDate, final ZonedDateTime endDate) {
Validate.notNull(startDate, "start date");
Validate.notNull(endDate, "end date");
Validate.isTrue(startDate.isBefore(endDate) || startDate.equals(endDate));
if (startDate.equals(endDate)) {
if (MonthDay.from(startDate).equals(_monthDay)) {
return new ZonedDateTime[] {startDate};
}
throw new IllegalArgumentException("Start date and end date were the same but the day of month and month of year were not those required");
}
ZonedDateTime date = startDate.with(_monthDay);
if (date.isBefore(startDate)) {
date = date.plusYears(1);
}
final List<ZonedDateTime> dates = new ArrayList<>();
while (!date.isAfter(endDate)) {
dates.add(date);
date = date.plusYears(1);
}
return dates.toArray(EMPTY_ZONED_DATE_TIME_ARRAY);
}
示例4: getDaysBetween
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
* Calculates the number of days in between two dates with the date count
* rule specified by the {@code TemporalAdjuster}.
*
* @param startDate the start date-time, not null
* @param includeStart whether to include the start
* @param endDate the end date-time, not null
* @param includeEnd whether to include the end
* @param convention the date adjuster, not null
* @return the number of days between two dates
*/
public static int getDaysBetween(final ZonedDateTime startDate, final boolean includeStart, final ZonedDateTime endDate, final boolean includeEnd, final TemporalAdjuster convention) {
LocalDate date = startDate.toLocalDate();
LocalDate localEndDate = endDate.toLocalDate();
int mult = 1;
if (startDate.isAfter(endDate)) {
date = endDate.toLocalDate();
localEndDate = startDate.toLocalDate();
mult = -1;
}
int result = includeStart ? 1 : 0;
while (!date.with(convention).equals(localEndDate)) {
date = date.with(convention);
result++;
}
return mult * (includeEnd ? result : result - 1);
}
示例5: getTimeBetween
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
* Computes the time between two dates using a user-supplied day count convention. Dates can be in any order.
* If date1 is after date2, the result will be negative.
* @param date1 The first date.
* @param date2 The second date.
* @param dayCount The day count.
* @param calendar the calendar.
* @return The time.
*/
public static double getTimeBetween(final ZonedDateTime date1, final ZonedDateTime date2, final DayCount dayCount, final Calendar calendar) {
ArgumentChecker.notNull(date1, "date1");
ArgumentChecker.notNull(date1, "date2");
ArgumentChecker.notNull(dayCount, "day count");
ArgumentChecker.notNull(calendar, "calendar");
// Implementation note: here we convert date2 to the same zone as date1 so we don't accidentally gain or lose a day.
final ZonedDateTime rebasedDate2 = date2.withZoneSameInstant(date1.getZone());
final boolean timeIsNegative = date1.isAfter(rebasedDate2); // date1 >= date2
if (!timeIsNegative) {
return dayCount.getDayCountFraction(date1, rebasedDate2, calendar);
}
return -1.0 * dayCount.getDayCountFraction(rebasedDate2, date1, calendar);
}
示例6: getUnadjustedDateSchedule
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
public static ZonedDateTime[] getUnadjustedDateSchedule(final ZonedDateTime effectiveDate, final ZonedDateTime accrualDate, final ZonedDateTime maturityDate,
final Period period) {
ArgumentChecker.notNull(effectiveDate, "effective date");
ArgumentChecker.notNull(accrualDate, "accrual date");
ArgumentChecker.notNull(maturityDate, "maturity date");
ArgumentChecker.notNull(period, "period");
if (effectiveDate.isAfter(maturityDate)) {
throw new IllegalArgumentException("Effective date was after maturity");
}
if (accrualDate.isAfter(maturityDate)) {
throw new IllegalArgumentException("Accrual date was after maturity");
}
// TODO what if there's no valid date between accrual date and maturity date?
final List<ZonedDateTime> dates = new ArrayList<>();
int nbPeriod = 1; // M 26-Aug
ZonedDateTime date = effectiveDate; // TODO this is only correct if effective date = accrual date
date = date.plus(period);
while (isWithinSwapLifetime(date, maturityDate)) { // REVIEW: could speed this up by working out how many periods between start and end date?
dates.add(date);
nbPeriod++; // M 26-Aug
date = effectiveDate.plus(period.multipliedBy(nbPeriod)); // M 26-Aug date = date.plus(period);
}
return dates.toArray(EMPTY_ARRAY);
}
示例7: visitAnnuityDefinition
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public Pair<LocalDate[], LocalDate[]> visitAnnuityDefinition(final AnnuityDefinition<? extends PaymentDefinition> annuity, final ZonedDateTime date) {
final int n = annuity.getNumberOfPayments();
final List<LocalDate> startDates = new ArrayList<>();
final List<LocalDate> endDates = new ArrayList<>();
int count = 0;
for (int i = 0; i < n; i++) {
final PaymentDefinition payment = annuity.getNthPayment(i);
final Pair<LocalDate, LocalDate> dates = payment.accept(COUPON_VISITOR);
if (!date.isAfter(payment.getPaymentDate())) {
startDates.add(dates.getFirst());
endDates.add(dates.getSecond());
count++;
}
}
return Pairs.of(startDates.toArray(new LocalDate[count]), endDates.toArray(new LocalDate[count]));
}
示例8: compare
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public int compare(User firstUser, User secondUser) {
ZonedDateTime firstUserParsedTimeStamp = ZonedDateTime.parse(firstUser.getJoinedTimeStamp());
ZonedDateTime secondUserParsedTimeStamp = ZonedDateTime.parse(secondUser.getJoinedTimeStamp());
if (firstUserParsedTimeStamp.isAfter(secondUserParsedTimeStamp)) {
return 1;
}
else {
return -1;
}
}
示例9: visitAnnuityDefinition
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public List<Set<Tenor>> visitAnnuityDefinition(AnnuityDefinition<? extends PaymentDefinition> annuity,
ZonedDateTime date) {
final int n = annuity.getNumberOfPayments();
final List<Set<Tenor>> tenors = new ArrayList<>();
for (int i = 0; i < n; i++) {
final PaymentDefinition payment = annuity.getNthPayment(i);
if (!date.isAfter(payment.getPaymentDate())) {
tenors.add(payment.accept(COUPON_VISITOR));
}
}
return tenors;
}
示例10: getTimeToExpiry
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
*
* @param date The date
* @return The time to expiry in years, where a year is defined as having 365.25 days
*/
public double getTimeToExpiry(final ZonedDateTime date) {
if (date.isAfter(getExpiry().getExpiry())) {
throw new IllegalArgumentException("Date " + date + " is after expiry " + getExpiry());
}
return DateUtils.getDifferenceInYears(date, getExpiry().getExpiry());
}
示例11: getAdjustedDate
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
* Compute the end date of a period from the start date, period, conventions and roll date adjuster. If the roll date
* adjuster is end of month, then only apply when the start date is last business day of the month and the period is a
* number of months or years, not days or weeks.
*
* @param startDate the start date
* @param period the period between the start and end date.
* @param convention the business day convention used to adjust the end date.
* @param calendar the calendar used to adjust the end date.
* @param rollDateAdjuster the roll date adjuster used to adjust the end date, before the conventions are applied.
* @return The end date.
*/
public static ZonedDateTime getAdjustedDate(
final ZonedDateTime startDate,
final Period period,
final BusinessDayConvention convention,
final Calendar calendar,
final RollDateAdjuster rollDateAdjuster) {
ArgumentChecker.notNull(startDate, "Start date");
ArgumentChecker.notNull(convention, "Convention");
ArgumentChecker.notNull(calendar, "Calendar");
ArgumentChecker.notNull(period, "Tenor");
ZonedDateTime endDate = startDate.plus(period); // Unadjusted date.
// Adjusted to month-end: when start date is last business day of the month, the end date is the last business day of the month.
if (rollDateAdjuster instanceof EndOfMonthRollDateAdjuster) {
final boolean isStartDateEOM = (startDate.getMonth() != getAdjustedDate(startDate, 1, calendar).getMonth());
if ((period.getDays() == 0) && isStartDateEOM) {
final BusinessDayConvention preceding = new PrecedingBusinessDayConvention();
return preceding.adjustDate(calendar, endDate.with(TemporalAdjusters.lastDayOfMonth()));
}
} else if (rollDateAdjuster != null) {
/*
* If we are rolling forward with a positive period and we have a day of month adjuster, we don't want to roll
* backwards.
*/
final ZonedDateTime rolledEndDate = endDate.with(rollDateAdjuster);
if (!period.isNegative() && rolledEndDate.isAfter(endDate)) {
endDate = rolledEndDate;
}
}
return convention.adjustDate(calendar, endDate); // Adjusted by Business day convention
}
示例12: visitAnnuityDefinition
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public double[] visitAnnuityDefinition(final AnnuityDefinition<? extends PaymentDefinition> annuity, final ZonedDateTime date) {
final int n = annuity.getNumberOfPayments();
final DoubleArrayList fractions = new DoubleArrayList();
for (int i = 0; i < n; i++) {
final PaymentDefinition payment = annuity.getNthPayment(i);
if (!date.isAfter(payment.getPaymentDate())) {
fractions.add(payment.accept(COUPON_VISITOR));
}
}
return fractions.toDoubleArray();
}
示例13: toDerivative
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public BillSecurity toDerivative(final ZonedDateTime date) {
ArgumentChecker.notNull(date, "Reference date");
ArgumentChecker.isTrue(!date.isAfter(_endDate), "Reference date {} is after end date {}", date, _endDate);
ZonedDateTime settlementDate = ScheduleCalculator.getAdjustedDate(date, _settlementDays, _calendar);
settlementDate = (settlementDate.isAfter(_endDate)) ? _endDate : settlementDate;
return toDerivative(date, settlementDate);
}
示例14: toDerivative
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public Annuity<? extends Payment> toDerivative(final ZonedDateTime date) {
ArgumentChecker.notNull(date, "date");
final List<Payment> resultList = new ArrayList<>();
for (int loopcoupon = 0; loopcoupon < _payments.length; loopcoupon++) {
if (!date.isAfter(_payments[loopcoupon].getPaymentDate())) {
resultList.add(_payments[loopcoupon].toDerivative(date));
}
}
return new Annuity<>(resultList.toArray(new Payment[resultList.size()]));
}
示例15: toDerivative
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* The first curve is the discounting curve for the first currency and the second curve is the discounting curve for the second currency.
*/
@Override
public InstrumentDerivative toDerivative(final ZonedDateTime date) {
ArgumentChecker.isTrue(!date.isAfter(_farLeg.getExchangeDate()), "date is after payment far date");
if (date.isAfter(_nearLeg.getExchangeDate())) { // Implementation note: only the far leg left.
return _farLeg.toDerivative(date);
}
final Forex nearLeg = _nearLeg.toDerivative(date);
final Forex farLeg = _farLeg.toDerivative(date);
return new ForexSwap(nearLeg, farLeg);
}