Java Code Examples for java.time.Month#FEBRUARY

The following examples show how to use java.time.Month#FEBRUARY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StringColumnMonthMapper.java    From jadira with Apache License 2.0 6 votes vote down vote up
@Override
public Month fromNonNullValue(String s) {
	
	switch(s) {
		case "JANUARY" : return Month.JANUARY;
		case "FEBRUARY" : return Month.FEBRUARY;
		case "MARCH" : return Month.MARCH;
		case "APRIL" : return Month.APRIL;
		case "MAY" : return Month.MAY;
		case "JUNE" : return Month.JUNE;
		case "JULY" : return Month.JULY;
		case "AUGUST" : return Month.AUGUST;
		case "SEPTEMBER" : return Month.SEPTEMBER;
		case "OCTOBER" : return Month.OCTOBER;
		case "NOVEMBER" : return Month.NOVEMBER;
		case "DECEMBER" : return Month.DECEMBER;
		default: throw new IllegalArgumentException("Seen unexpected Month: " + s);
	}
}
 
Example 2
Source File: MergeBotFactory.java    From skara with GNU General Public License v2.0 5 votes vote down vote up
private static Month toMonth(String s) {
    switch (s.toLowerCase()) {
        case "january":
            return Month.JANUARY;
        case "february":
            return Month.FEBRUARY;
        case "march":
            return Month.MARCH;
        case "april":
            return Month.APRIL;
        case "may":
            return Month.MAY;
        case "june":
            return Month.JUNE;
        case "july":
            return Month.JULY;
        case "august":
            return Month.AUGUST;
        case "september":
            return Month.SEPTEMBER;
        case "october":
            return Month.OCTOBER;
        case "november":
            return Month.NOVEMBER;
        case "december":
            return Month.DECEMBER;
        default:
            throw new IllegalArgumentException("Unknown month: " + s);
    }
}
 
Example 3
Source File: LocalDatePeriodCountCalculator.java    From objectlabkit with Apache License 2.0 5 votes vote down vote up
private int diff360EIsda(final LocalDate start, final LocalDate end) {
    if (start.equals(end)) {
        return 0;
    }
    int dayStart = start.getDayOfMonth();
    int dayEnd = end.getDayOfMonth();
    if (start.getMonth().length(start.isLeapYear()) == dayStart) {
        dayStart = CalculatorConstants.MONTH_30_DAYS;
    }
    if (end.getMonth() != Month.FEBRUARY && end.getMonth().length(end.isLeapYear()) == dayEnd) {
        dayEnd = CalculatorConstants.MONTH_30_DAYS;
    }
    return (end.getYear() - start.getYear()) * CalculatorConstants.YEAR_360 + (end.getMonthValue() - start.getMonthValue()) * CalculatorConstants.MONTH_30_DAYS + dayEnd - dayStart;
}
 
Example 4
Source File: DayCountConvention_30U_360.java    From finmath-lib with Apache License 2.0 5 votes vote down vote up
@Override
public double getDaycount(final LocalDate startDate, final LocalDate endDate) {
	if(startDate.isAfter(endDate)) {
		return -getDaycount(endDate,startDate);
	}

	int startDateDay 	= startDate.getDayOfMonth();
	final int startDateMonth 	= startDate.getMonthValue();
	final int startDateYear 	= startDate.getYear();

	int endDateDay 		= endDate.getDayOfMonth();
	final int endDateMonth 	= endDate.getMonthValue();
	final int endDateYear 	= endDate.getYear();

	if(
			isEndOfMonth &&
			startDate.getMonth() == Month.FEBRUARY &&
			startDate.getDayOfMonth() == startDate.lengthOfMonth() &&
			endDate.getMonth() == Month.FEBRUARY &&
			endDate.getDayOfMonth() == endDate.lengthOfMonth()
			) {
		endDateDay = 30;
	}

	if(
			isEndOfMonth &&
			startDate.getMonth() == Month.FEBRUARY &&
			startDate.getDayOfMonth() == startDate.lengthOfMonth()
			) {
		startDateDay = 30;
	}

	if(endDateDay > 30 && startDateDay >= 30) {
		endDateDay = 30;
	}
	startDateDay = Math.min(startDateDay,30);

	return (endDateYear - startDateYear) * 360.0 + (endDateMonth - startDateMonth) * 30.0 + (endDateDay - startDateDay);
}
 
Example 5
Source File: DayCountConvention_30U_360.java    From finmath-lib with Apache License 2.0 5 votes vote down vote up
@Override
public double getDaycount(final LocalDate startDate, final LocalDate endDate) {
	if(startDate.isAfter(endDate)) {
		return -getDaycount(endDate,startDate);
	}

	int startDateDay 	= startDate.getDayOfMonth();
	final int startDateMonth 	= startDate.getMonthValue();
	final int startDateYear 	= startDate.getYear();

	int endDateDay 		= endDate.getDayOfMonth();
	final int endDateMonth 	= endDate.getMonthValue();
	final int endDateYear 	= endDate.getYear();

	if(
			isEndOfMonth &&
			startDate.getMonth() == Month.FEBRUARY &&
			startDate.getDayOfMonth() == startDate.lengthOfMonth() &&
			endDate.getMonth() == Month.FEBRUARY &&
			endDate.getDayOfMonth() == endDate.lengthOfMonth()
			) {
		endDateDay = 30;
	}

	if(
			isEndOfMonth &&
			startDate.getMonth() == Month.FEBRUARY &&
			startDate.getDayOfMonth() == startDate.lengthOfMonth()
			) {
		startDateDay = 30;
	}

	if(endDateDay > 30 && startDateDay >= 30) {
		endDateDay = 30;
	}
	startDateDay = Math.min(startDateDay,30);

	return (endDateYear - startDateYear) * 360.0 + (endDateMonth - startDateMonth) * 30.0 + (endDateDay - startDateDay);
}
 
Example 6
Source File: PackedLocalDateTime.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
public static boolean isInQ1(long packedDateTime) {
  if (packedDateTime == missingValueIndicator()) return false;
  Month month = getMonth(packedDateTime);
  return month == Month.JANUARY || month == Month.FEBRUARY || month == Month.MARCH;
}
 
Example 7
Source File: PackedLocalDateTime.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
public static boolean isInFebruary(long packedDateTime) {
  return (packedDateTime != missingValueIndicator())
      && getMonth(packedDateTime) == Month.FEBRUARY;
}
 
Example 8
Source File: PackedLocalDateTime.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
public static boolean isInQ1(long packedDateTime) {
  if (packedDateTime == missingValueIndicator()) return false;
  Month month = getMonth(packedDateTime);
  return month == Month.JANUARY || month == Month.FEBRUARY || month == Month.MARCH;
}
 
Example 9
Source File: PackedLocalDateTime.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
public static boolean isInFebruary(long packedDateTime) {
  return (packedDateTime != missingValueIndicator())
      && getMonth(packedDateTime) == Month.FEBRUARY;
}
 
Example 10
Source File: FixedAssetServiceImpl.java    From axelor-open-suite with GNU Affero General Public License v3.0 4 votes vote down vote up
protected BigDecimal computeProrataTemporis(FixedAsset fixedAsset, boolean isFirstYear) {
  BigDecimal prorataTemporis = BigDecimal.ONE;
  if (isFirstYear
      && fixedAsset.getFixedAssetCategory().getIsProrataTemporis()
      && !fixedAsset.getAcquisitionDate().equals(fixedAsset.getFirstDepreciationDate())) {

    LocalDate acquisitionDate = fixedAsset.getAcquisitionDate();
    LocalDate depreciationDate = fixedAsset.getFirstDepreciationDate();

    int acquisitionYear = acquisitionDate.getYear();
    Month acquisitionMonth = acquisitionDate.getMonth();
    int acquisitionDay = acquisitionDate.getDayOfMonth();
    int depreciationYear = depreciationDate.getYear();
    Month depreciationMonth = depreciationDate.getMonth();
    int depreciationDay = depreciationDate.getDayOfMonth();

    // US way
    if (fixedAsset.getFixedAssetCategory().getIsUSProrataTemporis()) {

      if (acquisitionMonth == Month.FEBRUARY
          && depreciationMonth == Month.FEBRUARY
          && isLastDayOfFebruary(acquisitionYear, acquisitionDay)
          && isLastDayOfFebruary(depreciationYear, depreciationDay)) {
        depreciationDay = 30;
      }

      if (acquisitionMonth == Month.FEBRUARY
          && isLastDayOfFebruary(acquisitionYear, acquisitionDay)) {
        acquisitionDay = 30;
      }

      if (acquisitionDay >= 30 && depreciationDay > 30) {
        depreciationDay = 30;
      }

      if (acquisitionDay > 30) {
        acquisitionDay = 30;
      }

    } else { // European way

      if (acquisitionDay == 31) {
        acquisitionDay = 30;
      }

      if (depreciationDay == 31) {
        depreciationDay = 30;
      }
    }

    BigDecimal nbDaysBetweenAcqAndFirstDepDate =
        BigDecimal.valueOf(
                360 * (depreciationYear - acquisitionYear)
                    + 30 * (depreciationMonth.getValue() - acquisitionMonth.getValue())
                    + (depreciationDay - acquisitionDay))
            .setScale(calculationScale);
    BigDecimal nbDaysOfPeriod =
        BigDecimal.valueOf(fixedAsset.getPeriodicityInMonth() * 30).setScale(calculationScale);
    prorataTemporis =
        nbDaysBetweenAcqAndFirstDepDate
            .divide(nbDaysOfPeriod, BigDecimal.ROUND_HALF_EVEN)
            .setScale(calculationScale);
  }
  return prorataTemporis;
}