当前位置: 首页>>代码示例>>Java>>正文


Java ZonedDateTime.compareTo方法代码示例

本文整理汇总了Java中org.threeten.bp.ZonedDateTime.compareTo方法的典型用法代码示例。如果您正苦于以下问题:Java ZonedDateTime.compareTo方法的具体用法?Java ZonedDateTime.compareTo怎么用?Java ZonedDateTime.compareTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.threeten.bp.ZonedDateTime的用法示例。


在下文中一共展示了ZonedDateTime.compareTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compare

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public int compare(final String arg0, final String arg1) {
  try {
    final ZonedDateTime zdt0 = ZonedDateTime.parse(arg0);
    final ZonedDateTime zdt1 = ZonedDateTime.parse(arg1);
    return zdt0.compareTo(zdt1);
  } catch (final DateTimeParseException e1) {
    try {
      final LocalDate ld0 = LocalDate.parse(arg0);
      final LocalDate ld1 = LocalDate.parse(arg1);
      return ld0.compareTo(ld1);
    } catch (final DateTimeParseException e2) {
      return arg0.compareTo(arg1);
    }
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:17,代码来源:ExpiryAggregationFunction.java

示例2: execute

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public YieldCurveData execute(YieldCurveData curveData,
                              ValueSpecification valueSpecification,
                              FunctionExecutionContext executionContext) {
  ZonedDateTime valuationTime = ZonedDateTime.now(executionContext.getValuationClock());
  Map<ExternalIdBundle, Double> data = Maps.newHashMap(curveData.getDataPoints());
  Map<ExternalId, ExternalIdBundle> index = curveData.getIndex();
  for (YieldCurveBucketedShift shift : _shifts) {
    for (FixedIncomeStripWithSecurity strip : curveData.getCurveSpecification().getStrips()) {
      Period stripPeriod = strip.getTenor().getPeriod();
      Period shiftStart = shift.getStart();
      Period shiftEnd = shift.getEnd();
      ZonedDateTime stripTime = valuationTime.plus(stripPeriod);
      ZonedDateTime shiftStartTime = valuationTime.plus(shiftStart);
      ZonedDateTime shiftEndTime = valuationTime.plus(shiftEnd);

      if (stripTime.compareTo(shiftStartTime) >= 0 && stripTime.compareTo(shiftEndTime) <= 0) {
        ExternalIdBundle bundle = index.get(strip.getSecurityIdentifier());
        boolean future = (strip.getInstrumentType() == StripInstrumentType.FUTURE);
        Double originalData = data.get(bundle);
        Double stripData;

        // futures are quoted the other way round from other instruments
        if (future) {
          stripData = 1 - originalData;
        } else {
          stripData = originalData;
        }
        Double shiftedData;

        if (_shiftType == ScenarioShiftType.RELATIVE) {
          // add shift amount to 1. i.e. 10.pc actualy means 'value * 1.1' and -10.pc means 'value * 0.9'
          shiftedData = stripData * (shift.getShift() + 1);
        } else {
          shiftedData = stripData + shift.getShift();
        }
        Double shiftedStripData;

        if (future) {
          shiftedStripData = 1 - shiftedData;
        } else {
          shiftedStripData = shiftedData;
        }
        data.put(bundle, shiftedStripData);
        s_logger.debug("Shifting data {}, tenor {} by {} from {} to {}",
                       strip.getSecurityIdentifier(), strip.getTenor(), shift.getShift(), originalData, shiftedStripData);
      }
    }
  }
  return new YieldCurveData(curveData.getCurveSpecification(), data);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:52,代码来源:YieldCurveDataBucketedShiftManipulator.java

示例3: execute

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Override
public YieldCurveData execute(YieldCurveData curveData,
                              ValueSpecification valueSpecification,
                              FunctionExecutionContext executionContext) {
  ZonedDateTime valuationTime = ZonedDateTime.now(executionContext.getValuationClock());
  Map<ExternalIdBundle, Double> data = Maps.newHashMap(curveData.getDataPoints());
  Map<ExternalId, ExternalIdBundle> index = curveData.getIndex();
  for (YieldCurveDataPointShift shift : _shifts) {
    for (FixedIncomeStripWithSecurity strip : curveData.getCurveSpecification().getStrips()) {
      Period stripPeriod = strip.getTenor().getPeriod();
      Period shiftPeriod = shift.getTenor();
      ZonedDateTime stripTime = valuationTime.plus(stripPeriod);
      ZonedDateTime shiftStartTime = valuationTime.plus(shiftPeriod);

      if (stripTime.compareTo(shiftStartTime) == 0) {
        ExternalIdBundle bundle = index.get(strip.getSecurityIdentifier());
        boolean future = (strip.getInstrumentType() == StripInstrumentType.FUTURE);
        Double originalData = data.get(bundle);
        Double stripData;

        // futures are quoted the other way round from other instruments
        if (future) {
          stripData = 1 - originalData;
        } else {
          stripData = originalData;
        }
        Double shiftedData;

        if (_shiftType == ScenarioShiftType.RELATIVE) {
          // add shift amount to 1. i.e. 10.pc actualy means 'value * 1.1' and -10.pc means 'value * 0.9'
          shiftedData = stripData * (shift.getShift() + 1);
        } else {
          shiftedData = stripData + shift.getShift();
        }
        Double shiftedStripData;

        if (future) {
          shiftedStripData = 1 - shiftedData;
        } else {
          shiftedStripData = shiftedData;
        }
        data.put(bundle, shiftedStripData);
        s_logger.debug("Shifting data {}, tenor {} by {} from {} to {}",
                       strip.getSecurityIdentifier(), strip.getTenor(), shift.getShift(), originalData, shiftedStripData);
      }
    }
  }
  return new YieldCurveData(curveData.getCurveSpecification(), data);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:50,代码来源:YieldCurveDataPointShiftsManipulator.java


注:本文中的org.threeten.bp.ZonedDateTime.compareTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。