- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中java.time.YearMonth.isBefore()
方法的一些代码示例,展示了YearMonth.isBefore()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YearMonth.isBefore()
方法的具体详情如下:
包路径:java.time.YearMonth
类名称:YearMonth
方法名:isBefore
[英]Is this year-month before the specified year-month.
[中]是指定年份月份之前的本年月份。
代码示例来源:origin: stackoverflow.com
List<LocalDate> tooEarly = new ArrayList<>();
List<LocalDate> tooLate = new ArrayList<>();
List<LocalDate> justRight = new ArrayList<>();
for (String date : dates) {
YearMonth ym = YearMonth.from( date );
if( ym.isBefore( start ) ) {
tooEarly.add( date );
} else if( ! ym.isBefore( stop ) ) { // Using Half-Open approach where ending is *exclusive*. Use “( ym.isAfter( stop ) )” if you want inclusive ending.
tooLate.add( date );
} else {
justRight.add( date );
}
System.out.println( "ERROR unexpectedly went beyond the if-else-else." );
}
代码示例来源:origin: stackoverflow.com
YearMonth yearMonth = start ;
while ( yearMonth.isBefore( stop ) ) {
yearMonths.add( yearMonth ) ; // Add each incremented YearMonth to our collection.
// Set up next loop.
yearMonth.addMonths( 1 );
}
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMM-yyyy", Locale.ENGLISH);
YearMonth startDate = YearMonth.parse("Jan-2015", formatter);
YearMonth endDate = YearMonth.parse("Apr-2015", formatter);
while(startDate.isBefore(endDate)) {
System.out.println(startDate.format(formatter));
startDate = startDate.plusMonths(1);
}
}
代码示例来源:origin: stackoverflow.com
YearMonth ym = ymStart;
do {
int daysInMonth = ym.lengthOfMonth ();
String monthName = ym.getMonth ().getDisplayName ( TextStyle.FULL , Locale.CANADA_FRENCH );
System.out.println ( ym + " : " + daysInMonth + " jours en " + monthName );
// Prepare for next loop.
ym = ym.plusMonths ( 1 );
} while ( ym.isBefore ( ymStop ) );
代码示例来源:origin: br.com.jarch/jarch-util
public static Collection<YearMonth> generateFromLocalDate(LocalDate start, LocalDate end) {
YearMonth yearMonthActual = YearMonth.of(start.getYear(), start.getMonth());
YearMonth yearMonthEnd = YearMonth.of(end.getYear(), end.getMonth());
List<YearMonth> listYearMonthReturn = new ArrayList<>();
do {
listYearMonthReturn.add(yearMonthActual);
yearMonthActual = yearMonthActual.plusMonths(1);
} while (yearMonthActual.isBefore(yearMonthEnd));
listYearMonthReturn.add(yearMonthEnd);
return listYearMonthReturn;
}
}
代码示例来源:origin: br.com.jarch/jarch-utils
public static Collection<YearMonth> generateFromLocalDate(LocalDate start, LocalDate end) {
YearMonth yearMonthActual = YearMonth.of(start.getYear(), start.getMonth());
YearMonth yearMonthEnd = YearMonth.of(end.getYear(), end.getMonth());
List<YearMonth> listYearMonthReturn = new ArrayList<>();
do {
listYearMonthReturn.add(yearMonthActual);
yearMonthActual = yearMonthActual.plusMonths(1);
} while (yearMonthActual.isBefore(yearMonthEnd));
listYearMonthReturn.add(yearMonthEnd);
return listYearMonthReturn;
}
}
代码示例来源:origin: OpenGamma/Strata
@Override
public double value(PriceIndexObservation observation) {
YearMonth fixingMonth = observation.getFixingMonth();
// If fixing in the past, check time series and returns the historic month price index if present
if (fixingMonth.isBefore(YearMonth.from(valuationDate))) {
OptionalDouble fixing = fixings.get(fixingMonth.atEndOfMonth());
if (fixing.isPresent()) {
return fixing.getAsDouble();
}
}
throw new MarketDataNotFoundException("Unable to query forward value for historic index " + index);
}
代码示例来源:origin: OpenGamma/Strata
@Override
public double value(PriceIndexObservation observation) {
YearMonth fixingMonth = observation.getFixingMonth();
// If fixing in the past, check time series and returns the historic month price index if present
if (fixingMonth.isBefore(YearMonth.from(valuationDate))) {
OptionalDouble fixing = fixings.get(fixingMonth.atEndOfMonth());
if (fixing.isPresent()) {
return fixing.getAsDouble();
}
}
// otherwise, return the estimate from the curve.
double nbMonth = numberOfMonths(fixingMonth);
return curve.yValue(nbMonth);
}
代码示例来源:origin: stackoverflow.com
YearMonth yearMonth = startYm;
do {
int days = 0;
if ( startYm.equals ( stopYm ) ) { // If within the same (single) month.
days = ( int ) ChronoUnit.DAYS.between ( start , stop );
} else if ( yearMonth.equals ( startYm ) ) { // If on the first month of multiple months, count days.
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.
} else if ( yearMonth.isAfter ( startYm ) && yearMonth.isBefore ( stopYm ) ) { // If on the in-between months, ask for the days of that month.
days = yearMonth.lengthOfMonth ();
} else if ( yearMonth.equals ( stopYm ) ) { // If on the last of multiple months.
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.
} else {
System.out.println ( "ERROR - Reached impossible point." );
// FIXME: Handle error condition.
}
map.put ( yearMonth , days ); // Cast long to int, auto-boxed to Integer.
// Prep for next loop.
yearMonth = yearMonth.plusMonths ( 1 );
} while ( ! yearMonth.isAfter ( stopYm ) );
代码示例来源:origin: br.com.jarch/jarch-annotation
YearMonth dateBegin = (YearMonth) objectBegin;
YearMonth dateEnd = (YearMonth) objectEnd;
valid = dateBegin.isBefore(dateEnd);
代码示例来源:origin: OpenGamma/Strata
@Override
public PointSensitivityBuilder valuePointSensitivity(PriceIndexObservation observation) {
YearMonth fixingMonth = observation.getFixingMonth();
// If fixing in the past, check time series and returns the historic month price index if present
if (fixingMonth.isBefore(YearMonth.from(valuationDate))) {
if (fixings.get(fixingMonth.atEndOfMonth()).isPresent()) {
return PointSensitivityBuilder.none();
}
}
return InflationRateSensitivity.of(observation, 1d);
}
代码示例来源:origin: OpenGamma/Strata
@Override
public PointSensitivityBuilder valuePointSensitivity(PriceIndexObservation observation) {
YearMonth fixingMonth = observation.getFixingMonth();
// If fixing in the past, check time series and returns the historic month price index if present
if (fixingMonth.isBefore(YearMonth.from(valuationDate))) {
if (fixings.get(fixingMonth.atEndOfMonth()).isPresent()) {
return PointSensitivityBuilder.none();
}
}
throw new MarketDataNotFoundException("Unable to query forward value sensitivity for historic index " + index);
}
代码示例来源:origin: OpenGamma/Strata
private UnitParameterSensitivities unitParameterSensitivity(YearMonth month) {
// If fixing in the past, check time series and returns the historic month price index if present
if (month.isBefore(YearMonth.from(valuationDate))) {
if (fixings.get(month.atEndOfMonth()).isPresent()) {
return UnitParameterSensitivities.empty();
}
}
double nbMonth = numberOfMonths(month);
return UnitParameterSensitivities.of(curve.yValueParameterSensitivity(nbMonth));
}
代码示例来源:origin: OpenGamma/Strata
public void test_value_futfixing() {
for (int i = 0; i < TEST_MONTHS.length; i++) {
double valueComputed = INSTANCE_WITH_FUTFIXING.value(TEST_OBS[i]);
YearMonth fixingMonth = TEST_OBS[i].getFixingMonth();
double valueExpected;
if (fixingMonth.isBefore(YearMonth.from(VAL_DATE_2)) && USCPI_TS.containsDate(fixingMonth.atEndOfMonth())) {
valueExpected = USCPI_TS.get(fixingMonth.atEndOfMonth()).getAsDouble();
} else {
double x = YearMonth.from(VAL_DATE_2).until(fixingMonth, MONTHS);
valueExpected = CURVE_INFL2.yValue(x);
}
assertEquals(valueComputed, valueExpected, TOLERANCE_VALUE, "test " + i);
}
}
代码示例来源:origin: OpenGamma/Strata
public void test_value_pts_sensitivity_futfixing() {
for (int i = 0; i < TEST_MONTHS.length; i++) {
PointSensitivityBuilder ptsComputed = INSTANCE_WITH_FUTFIXING.valuePointSensitivity(TEST_OBS[i]);
YearMonth fixingMonth = TEST_OBS[i].getFixingMonth();
PointSensitivityBuilder ptsExpected;
if (fixingMonth.isBefore(YearMonth.from(VAL_DATE_2)) && USCPI_TS.containsDate(fixingMonth.atEndOfMonth())) {
ptsExpected = PointSensitivityBuilder.none();
} else {
ptsExpected = InflationRateSensitivity.of(TEST_OBS[i], 1d);
}
assertTrue(ptsComputed.build().equalWithTolerance(ptsExpected.build(), TOLERANCE_VALUE), "test " + i);
}
}
代码示例来源:origin: OpenGamma/Strata
public void test_value_parameter_sensitivity_futfixing() {
for (int i = 0; i < TEST_MONTHS.length; i++) {
YearMonth fixingMonth = TEST_OBS[i].getFixingMonth();
if (!fixingMonth.isBefore(YearMonth.from(VAL_DATE_2)) && !USCPI_TS.containsDate(fixingMonth.atEndOfMonth())) {
InflationRateSensitivity ptsExpected = (InflationRateSensitivity) InflationRateSensitivity.of(TEST_OBS[i], 1d);
CurrencyParameterSensitivities psComputed = INSTANCE_WITH_FUTFIXING.parameterSensitivity(ptsExpected);
double x = YearMonth.from(VAL_DATE_2).until(fixingMonth, MONTHS);
UnitParameterSensitivities sens1 = UnitParameterSensitivities.of(CURVE_INFL2.yValueParameterSensitivity(x));
CurrencyParameterSensitivities psExpected =
sens1.multipliedBy(ptsExpected.getCurrency(), ptsExpected.getSensitivity());
assertTrue(psComputed.equalWithTolerance(psExpected, TOLERANCE_DELTA), "test " + i);
}
}
}
代码示例来源:origin: OpenGamma/Strata
ArgChecker.isTrue(lastMonth.isBefore(valuationMonth), "Last fixing month must be before valuation date");
double nbMonth = valuationMonth.until(lastMonth, MONTHS);
DoubleArray x = curveWithoutFixing.getXValues();
我正在尝试检查给定日期是否早于今天的日期: const today = moment(new Date(), "YYYY-MM-DD", true); const isBeforeToday = mo
本文整理了Java中java.time.ZonedDateTime.isBefore()方法的一些代码示例,展示了ZonedDateTime.isBefore()的具体用法。这些代码示例主要来源于Gi
本文整理了Java中java.time.YearMonth.isBefore()方法的一些代码示例,展示了YearMonth.isBefore()的具体用法。这些代码示例主要来源于Github/Sta
我一直在使用 momentJS 来检测没有日期的 future 日期。这是我的代码和结果: moment('09/2010').isBefore(moment().format('MM/YYYY'),
需要比较的两个时刻是: 今天在某个时区 (Wed Oct 12 2016 08:42:19 GMT+0000) 从日历中选择一个日期(例如 2016-10-11) 这是我的工作方式: var date
我在使用 moment js 库时遇到问题。函数 isBefore 有时会返回错误的结果。下面的代码应该返回 true,而不是 false 值。 var clockIn = moment('1/5/2
我的控制台日志给出了意外的输出。 var bool = (moment("2017-04-08 23:00:00").isBefore(moment("2017-04-09 01:00:00", 'd
本文整理了Java中org.threeten.extra.YearQuarter.isBefore()方法的一些代码示例,展示了YearQuarter.isBefore()的具体用法。这些代码示例主要
进行比较时,OffsetDateTime isAfter 和 isBefore 方法是否处理时区? 因此,如果一个 OffsetDateTime 采用 PST,另一个采用 UTC,它会自动进行时区转换
查找时间介于 startTime 和 endTime 之间的问题。我有这样的配置 timeframe1 = C1|04:00|11.59 timeframe2 = C2|20.00|03:59 tim
我想将两个日期与今天的日期进行比较。 isAfter 和 isBefore 最适合这个吗? isAfter 和 isBefore 无法检测到一天的变化。比方说: If today is 20 Nov.
本文整理了Java中com.koolearn.klibrary.text.view.ZLTextRegion.isBefore()方法的一些代码示例,展示了ZLTextRegion.isBefore(
我正在使用 Moment.js 在前端处理一些日期标签。我遇到了一个晦涩的场景,希望 MomentJS 专家对我进行类(class)纠正。 考虑以下传入字符串值的实现,"2018-08-28T20:2
有没有办法只比较具有 isBefore 函数的 DateTime 对象的日期? 例如, DateTime start = new DateTime(Long.parseLong()); DateTim
I want to check if a given DateTime is before or after current DateTime. I was converting input time
我是一名优秀的程序员,十分优秀!