List of usage examples for org.joda.time LocalDate monthOfYear
public Property monthOfYear()
From source file:com.gst.portfolio.savings.domain.interest.PostingPeriod.java
License:Apache License
private static LocalDate determineInterestPeriodEndDateFrom(final LocalDate periodStartDate, final SavingsCompoundingInterestPeriodType interestPeriodType, final LocalDate upToInterestCalculationDate) { LocalDate periodEndDate = upToInterestCalculationDate; switch (interestPeriodType) { case INVALID: break;/*from w w w. j av a2 s . c o m*/ case DAILY: periodEndDate = periodStartDate; break; // case WEEKLY: // periodEndDate = periodStartDate.dayOfWeek().withMaximumValue(); // break; // case BIWEEKLY: // final LocalDate closestEndOfWeek = // periodStartDate.dayOfWeek().withMaximumValue(); // periodEndDate = closestEndOfWeek.plusWeeks(1); // break; case MONTHLY: // produce period end date on last day of current month periodEndDate = periodStartDate.dayOfMonth().withMaximumValue(); break; case QUATERLY: // // jan 1st to mar 31st, 1st apr to jun 30, jul 1st to sept // 30, // // oct 1st to dec 31 int year = periodStartDate.getYearOfEra(); int monthofYear = periodStartDate.getMonthOfYear(); if (monthofYear <= 3) { periodEndDate = new DateTime().withDate(year, 3, 31).toLocalDate(); } else if (monthofYear <= 6) { periodEndDate = new DateTime().withDate(year, 6, 30).toLocalDate(); } else if (monthofYear <= 9) { periodEndDate = new DateTime().withDate(year, 9, 30).toLocalDate(); } else if (monthofYear <= 12) { periodEndDate = new DateTime().withDate(year, 12, 31).toLocalDate(); } break; case BI_ANNUAL: // // jan 1st to 30, jul 1st to dec 31 year = periodStartDate.getYearOfEra(); monthofYear = periodStartDate.getMonthOfYear(); if (monthofYear <= 6) { periodEndDate = new DateTime().withDate(year, 6, 30).toLocalDate(); } else if (monthofYear <= 12) { periodEndDate = new DateTime().withDate(year, 12, 31).toLocalDate(); } break; case ANNUAL: periodEndDate = periodStartDate.monthOfYear().withMaximumValue(); periodEndDate = periodEndDate.dayOfMonth().withMaximumValue(); break; // case NO_COMPOUNDING_SIMPLE_INTEREST: // periodEndDate = periodStartDate.monthOfYear().withMaximumValue(); // periodEndDate = periodEndDate.dayOfMonth().withMaximumValue(); // break; } return periodEndDate; }
From source file:com.ideaspymes.arthyweb.ventas.web.controllers.ResumenMetasBean.java
public Integer calculaDiasTrabajados(Date fecha) { org.joda.time.LocalDate endDate = new org.joda.time.LocalDate(fecha); org.joda.time.LocalDate startDate = new org.joda.time.LocalDate(endDate.year().get(), endDate.monthOfYear().get(), 1); return getDiasTrabajadosIncluyendoHoy(startDate, endDate) - getHolydaysIgnoreWeekends(startDate.toDate(), fecha); }
From source file:com.splicemachine.db.iapi.types.SQLDate.java
License:Apache License
/** * Get the month name from the encodedDate, * 'January' ,'February', etc./*from w w w.ja v a 2 s .com*/ * * @param encodedDate the encoded date * @return month name. */ static String getMonthName(int encodedDate) { LocalDate date = new LocalDate(getYear(encodedDate), getMonth(encodedDate), getDay(encodedDate)); return date.monthOfYear().getAsText(); }
From source file:net.sourceforge.fenixedu.domain.Tutorship.java
License:Open Source License
public static void createTutorship(Teacher teacher, StudentCurricularPlan scp, Integer endMonth, Integer endYear) {//from w w w . j ava 2s. com LocalDate currentDate = new LocalDate(); Partial tutorshipStartDate = new Partial( new DateTimeFieldType[] { DateTimeFieldType.year(), DateTimeFieldType.monthOfYear() }, new int[] { currentDate.year().get(), currentDate.monthOfYear().get() }); Partial tutorshipEndDate = new Partial( new DateTimeFieldType[] { DateTimeFieldType.year(), DateTimeFieldType.monthOfYear() }, new int[] { endYear, endMonth }); Tutorship tutorship = new Tutorship(teacher, tutorshipStartDate, tutorshipEndDate, scp); TutorshipLog tutorshipLog = new TutorshipLog(); if (scp.getRegistration() != null && scp.getRegistration().getStudentCandidacy() != null && scp.getRegistration().getStudentCandidacy().getPlacingOption() != null) { switch (scp.getRegistration().getStudentCandidacy().getPlacingOption()) { case 1: { tutorshipLog.setOptionNumberDegree(Option.ONE); break; } case 2: { tutorshipLog.setOptionNumberDegree(Option.TWO); break; } case 3: { tutorshipLog.setOptionNumberDegree(Option.THREE); break; } case 4: { tutorshipLog.setOptionNumberDegree(Option.FOUR); break; } case 5: { tutorshipLog.setOptionNumberDegree(Option.FIVE); break; } case 6: { tutorshipLog.setOptionNumberDegree(Option.SIX); break; } default: { tutorshipLog.setOptionNumberDegree(null); } } } tutorship.setTutorshipLog(tutorshipLog); }
From source file:org.alexlg.bankit.controllers.AccountController.java
License:Open Source License
/** * Build a set of MonthOps for all future ops : "manual" or costs (beyond 2 days of current) * @param day Current day//from w w w. j av a 2 s .c o m * @param futurePlannedOps List of manual future operations * @param costs List of costs * @param balance Start balance * @param nbMonth Number of month to build in addition to the current month. * @return A set of MonthOps for each month planned */ protected Set<MonthOps> buildFutureOps(LocalDate day, List<Operation> futurePlannedOps, List<Cost> costs, BigDecimal balance, int nbMonth) { Set<MonthOps> futureOps = new TreeSet<MonthOps>(); //going through all months for (int i = 0; i < nbMonth + 1; i++) { LocalDate monthDate = day.monthOfYear().addToCopy(i); int lastDayOfMonth = monthDate.dayOfMonth().getMaximumValue(); MonthOps monthOps = new MonthOps(monthDate, balance); futureOps.add(monthOps); //adding "manual" operation of the current month if (futurePlannedOps.size() > 0) { //loop an add all operation of the month for (Operation op : futurePlannedOps) { if (new LocalDate(op.getOperationDate()).getMonthOfYear() == monthDate.getMonthOfYear()) { op.setAuto(false); monthOps.addOp(op); } } } //adding costs of the current month LocalDate costStartDay = day.plusDays(2); for (Cost cost : costs) { int costDay = cost.getDay(); //if the operation is planned after the last day of month //set it to the last day if (costDay > lastDayOfMonth) costDay = lastDayOfMonth; LocalDate opDate = new LocalDate(monthDate.getYear(), monthDate.getMonthOfYear(), costDay); //checking if we add the cost (the date is after current+2) if (opDate.isAfter(costStartDay)) { Operation op = new Operation(); //setting a fake id for comparison (as we put the operation in the set) op.setOperationId(cost.getCostId() + i); op.setOperationDate(opDate.toDate()); op.setPlanned(cost.getAmount()); op.setLabel(cost.getLabel()); op.setCategory(cost.getCategory()); op.setAuto(true); monthOps.addOp(op); } } //saving current balance for next monthOp balance = monthOps.getBalance(); } return futureOps; }
From source file:org.apache.niolex.common.joda.Joda.java
License:Apache License
/** * @param args//from w w w.j ava2 s. c o m */ public static void main(String[] args) { Locale.setDefault(Locale.ENGLISH); // --- ? LocalDate now = new LocalDate(); LocalDate lastDayOfPreviousMonth = now.minusMonths(1).dayOfMonth().withMaximumValue(); // - Print SystemUtil.println(lastDayOfPreviousMonth.toString()); // --- 11 ? LocalDate electionDate = now.monthOfYear().setCopy(11) // November .dayOfMonth() // Access Day Of Month Property .withMinimumValue() // Get its minimum value .plusDays(6) // Add 6 days .dayOfWeek() // Access Day Of Week Property .setCopy("Monday") // Set to Monday (it will round down) .plusDays(1); // Gives us Tuesday // - Print SystemUtil.println(electionDate.toString()); // --- ?? LocalDate then = now.plusWeeks(2); // - Print SystemUtil.println(then.toString()); }
From source file:org.gnucash.android.model.Recurrence.java
License:Apache License
/** * Return the name of the current period * @return String of current period//from w w w . j ava 2 s . c o m */ public String getTextOfCurrentPeriod(int periodNum) { LocalDate startDate = new LocalDate(mPeriodStart.getTime()); switch (mPeriodType) { case DAY: return startDate.dayOfWeek().getAsText(); case WEEK: return startDate.weekOfWeekyear().getAsText(); case MONTH: return startDate.monthOfYear().getAsText(); case YEAR: return startDate.year().getAsText(); } return "Period " + periodNum; }