List of usage examples for org.joda.time LocalDate toDateTimeAtCurrentTime
public DateTime toDateTimeAtCurrentTime()
From source file:com.axelor.apps.account.service.cfonb.CfonbExportService.java
License:Open Source License
/** * Fonction permettant de crer un enregistrement 'metteur' pour un export de prlvement de mensu * @param company/*www. ja v a 2 s.c o m*/ * Une socit * @param localDate * Une date * @return * Un enregistrement 'emetteur' * @throws AxelorException */ private String createSenderMonthlyExportCFONB(LocalDate localDate, BankDetails bankDetails) throws AxelorException { DateFormat ddmmFormat = new SimpleDateFormat("ddMM"); String date = ddmmFormat.format(localDate.toDateTimeAtCurrentTime().toDate()); date += String.format("%s", StringTool.truncLeft(String.format("%s", localDate.getYear()), 1)); // Rcupration des valeurs String a = this.cfonbConfig.getSenderRecordCodeExportCFONB(); // Code enregistrement String b1 = this.cfonbConfig.getDirectDebitOperationCodeExportCFONB(); // Code opration String b2 = ""; // Zone rserve String b3 = this.cfonbConfig.getSenderNumExportCFONB(); // Numro d'metteur String c1One = ""; // Zone rserve String c1Two = date; // Date d'chance String c2 = this.cfonbConfig.getSenderNameCodeExportCFONB(); // Nom/Raison sociale du donneur d'ordre String d1One = ""; // Rfrence de la remise String d1Two = ""; // Zone rserve String d2 = ""; // Zone rserve String d3 = bankDetails.getSortCode(); // Code guichet de la banque du donneur d'ordre String d4 = bankDetails.getAccountNbr(); // Numro de compte du donneur dordre String e = ""; // Zone rserve String f = ""; // Zone rserve String g1 = bankDetails.getBankCode(); // Code tablissement de la banque du donneur d'ordre String g2 = ""; // Zone rserve // Tronquage / remplissage droite (chaine de caractre) b2 = StringTool.fillStringRight(b2, ' ', 8); b3 = StringTool.fillStringRight(b3, ' ', 6); c1One = StringTool.fillStringRight(c1One, ' ', 7); c2 = StringTool.fillStringRight(c2, ' ', 24); d1One = StringTool.fillStringRight(d1One, ' ', 7); d1Two = StringTool.fillStringRight(d1Two, ' ', 17); d2 = StringTool.fillStringRight(d2, ' ', 8); d4 = StringTool.fillStringRight(d4, ' ', 11); e = StringTool.fillStringRight(e, ' ', 16); f = StringTool.fillStringRight(f, ' ', 31); g2 = StringTool.fillStringRight(g2, ' ', 6); // Tronquage / remplissage gauche (nombre) a = StringTool.fillStringLeft(a, '0', 2); b1 = StringTool.fillStringLeft(b1, '0', 2); c1Two = StringTool.fillStringLeft(c1Two, '0', 5); d3 = StringTool.fillStringLeft(d3, '0', 5); g1 = StringTool.fillStringLeft(g1, '0', 5); // Vrification AN / N / A cfonbToolService.testDigital(a, 0); cfonbToolService.testDigital(b1, 0); cfonbToolService.testDigital(d3, 0); cfonbToolService.testDigital(g1, 0); // cration de l'enregistrement return a + b1 + b2 + b3 + c1One + c1Two + c2 + d1One + d1Two + d2 + d3 + d4 + e + f + g1 + g2; }
From source file:me.vertretungsplan.parser.ParserUtils.java
License:Mozilla Public License
static LocalDate parseDate(String string) { if (string == null) return null; reinitIfNeeded();/* w w w. ja va 2 s .c o m*/ string = string.replace("Stand:", "").replace("Import:", "").replaceAll(", Woche [A-Z]", "").trim(); int i = 0; for (DateTimeFormatter f : dateFormatters) { try { LocalDate d = f.parseLocalDate(string); if (dateFormats[i].contains("yyyy")) { return d; } else { Duration currentYearDifference = abs(new Duration(DateTime.now(), d.toDateTimeAtCurrentTime())); Duration lastYearDifference = abs( new Duration(DateTime.now(), d.minusYears(1).toDateTimeAtCurrentTime())); Duration nextYearDifference = abs( new Duration(DateTime.now(), d.plusYears(1).toDateTimeAtCurrentTime())); if (lastYearDifference.isShorterThan(currentYearDifference)) { return DateTimeFormat.forPattern(dateFormats[i]).withLocale(Locale.GERMAN) .withDefaultYear(f.getDefaultYear() - 1).parseLocalDate(string); } else if (nextYearDifference.isShorterThan(currentYearDifference)) { return DateTimeFormat.forPattern(dateFormats[i]).withLocale(Locale.GERMAN) .withDefaultYear(f.getDefaultYear() + 1).parseLocalDate(string); } else { return d; } } } catch (IllegalArgumentException e) { // Does not match this format, try the next one } i++; } // Does not match any known format :( return null; }
From source file:net.sourceforge.fenixedu.domain.candidacyProcess.IndividualCandidacy.java
License:Open Source License
protected void checkParameters(final Person person, final IndividualCandidacyProcess process, final LocalDate candidacyDate) { /*/*from w w w.j a v a 2 s . com*/ * 31/03/2009 - The candidacy will not be associated with a Person if it * is submited externally (not in administrative office) * * * if (person == null) { throw new * DomainException("error.IndividualCandidacy.invalid.person"); } */ if (process == null) { throw new DomainException("error.IndividualCandidacy.invalid.process"); } if (candidacyDate == null || !process.hasOpenCandidacyPeriod(candidacyDate.toDateTimeAtCurrentTime())) { throw new DomainException("error.IndividualCandidacy.invalid.candidacyDate", process.getCandidacyStart().toString(DateFormatUtil.DEFAULT_DATE_FORMAT), process.getCandidacyEnd().toString(DateFormatUtil.DEFAULT_DATE_FORMAT)); } }
From source file:net.sourceforge.fenixedu.domain.ExecutionYear.java
License:Open Source License
static public ExecutionYear readByDateTime(final LocalDate localDate) { return executionYearSearchCache.findByDateTime(localDate.toDateTimeAtCurrentTime()); }
From source file:op.allowance.PnlAllowance.java
License:Open Source License
private void updateCarrySums(Resident resident, LocalDate pit, BigDecimal amount) { String prevKey = getKey(resident, SYSCalendar.eom(pit.minusMonths(1))); if (!carrySums.containsKey(prevKey)) { carrySums.put(prevKey, AllowanceTools.getSUM(resident, SYSCalendar.eom(pit).minusMonths(1))); }//from w w w .j a va 2 s .c om // update carrysums for (LocalDate month = SYSCalendar.eom(pit); month .compareTo(SYSCalendar.eoy(new LocalDate())) <= 0; month = SYSCalendar.eom(month.plusMonths(1))) { OPDE.debug(month.toString("yyyy-MM-dd")); final String key = getKey(resident, month); if (!carrySums.containsKey(key)) { prevKey = getKey(resident, SYSCalendar.eom(month.minusMonths(1))); carrySums.put(key, carrySums.get(prevKey).add(amount)); } else { carrySums.put(key, carrySums.get(key).add(amount)); } contentmap.remove(key); } // fix minmax interval Interval myMinMax = new Interval(minmax.get(resident).getFirst().toDateTimeAtStartOfDay(), SYSCalendar.eod(minmax.get(resident).getSecond())); if (myMinMax.isBefore(pit.toDateTimeAtCurrentTime())) { minmax.put(resident, new Pair(minmax.get(resident).getFirst(), SYSCalendar.eom(pit))); } else if (myMinMax.isAfter(pit.toDateTimeAtCurrentTime())) { minmax.put(resident, new Pair(SYSCalendar.bom(pit), minmax.get(resident).getSecond())); } }
From source file:op.tools.SYSCalendar.java
License:Open Source License
public static DateTime midOfDay(LocalDate d) { DateTime dt = d.toDateTimeAtCurrentTime(); return dt.withHourOfDay(12).withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0); }
From source file:org.apache.sqoop.connector.hbase.HbaseExecutor.java
License:Apache License
public void addBatch(Object[] array, Schema schema) { try {/*from www. j av a 2 s . co m*/ Column[] schemaColumns = schema.getColumnsArray(); for (int i = 0; i < array.length; i++) { Column schemaColumn = schemaColumns[i]; switch (schemaColumn.getType()) { case DATE: // convert the JODA date to sql date LocalDate date = (LocalDate) array[i]; java.sql.Date sqlDate = new java.sql.Date(date.toDateTimeAtCurrentTime().getMillis()); preparedStatement.setObject(i + 1, sqlDate); break; case DATE_TIME: // convert the JODA date time to sql date DateTime dateTime = (DateTime) array[i]; Timestamp timestamp = new Timestamp(dateTime.getMillis()); preparedStatement.setObject(i + 1, timestamp); break; case TIME: // convert the JODA time to sql date LocalTime time = (LocalTime) array[i]; java.sql.Time sqlTime = new java.sql.Time(time.toDateTimeToday().getMillis()); preparedStatement.setObject(i + 1, sqlTime); break; default: // for anything else preparedStatement.setObject(i + 1, array[i]); } } preparedStatement.addBatch(); } catch (SQLException e) { logSQLException(e); throw new SqoopException(GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0002, e); } }
From source file:org.fenixedu.academic.domain.candidacyProcess.IndividualCandidacy.java
License:Open Source License
protected void checkParameters(final Person person, final IndividualCandidacyProcess process, final LocalDate candidacyDate) { /*//from w w w . jav a2 s . co m * 31/03/2009 - The candidacy will not be associated with a Person if it * is submited externally (not in administrative office) * * * if (person == null) { throw new * DomainException("error.IndividualCandidacy.invalid.person"); } */ if (process == null) { throw new DomainException("error.IndividualCandidacy.invalid.process"); } if (candidacyDate == null || !process.hasOpenCandidacyPeriod(candidacyDate.toDateTimeAtCurrentTime())) { throw new DomainException("error.IndividualCandidacy.invalid.candidacyDate", process.getCandidacyStart().toString("dd/MM/yyyy"), process.getCandidacyEnd().toString("dd/MM/yyyy")); } }
From source file:org.fenixedu.treasury.ui.document.manageinvoice.DebitNoteController.java
License:Open Source License
@Atomic public DebitNote createDebitNote(DebtAccount payorDebtAccount, DebtAccount debtAccount, DocumentNumberSeries documentNumberSeries, LocalDate documentDate, LocalDate documentDueDate, String originDocumentNumber, String documentObservations) { if (payorDebtAccount == null) { payorDebtAccount = debtAccount;/* w ww . ja va2 s . co m*/ } DebitNote debitNote = DebitNote.create(debtAccount, payorDebtAccount, documentNumberSeries, documentDate.toDateTimeAtCurrentTime(), documentDueDate, originDocumentNumber); debitNote.setDocumentObservations(documentObservations); return debitNote; }
From source file:org.kuali.kpme.tklm.leave.calendar.validation.LeaveCalendarValidationUtil.java
License:Educational Community License
public static List<String> validateAvailableLeaveBalanceForUsage(String earnCode, String leaveStartDateString, String leaveEndDateString, BigDecimal leaveAmount, LeaveBlock updatedLeaveBlock) { List<String> errors = new ArrayList<String>(); boolean earnCodeChanged = false; BigDecimal oldAmount = null;/*from w w w . jav a 2s.c o m*/ if (leaveAmount == null) { leaveAmount = TKUtils.getHoursBetween(TKUtils.formatDateString(leaveStartDateString).toDate().getTime(), TKUtils.formatDateString(leaveEndDateString).toDate().getTime()); } if (updatedLeaveBlock != null) { if (!updatedLeaveBlock.getEarnCode().equals(earnCode)) { earnCodeChanged = true; } if (!updatedLeaveBlock.getLeaveAmount().equals(leaveAmount)) { oldAmount = updatedLeaveBlock.getLeaveAmount(); } } LocalDate startDate = TKUtils.formatDateString(leaveStartDateString); LocalDate endDate = TKUtils.formatDateString(leaveEndDateString); long daysSpan = TKUtils.getDaysBetween(startDate, endDate); EarnCode earnCodeObj = HrServiceLocator.getEarnCodeService().getEarnCode(earnCode, endDate); if (earnCodeObj != null && earnCodeObj.getAllowNegativeAccrualBalance().equals("N")) { AccrualCategory accrualCategory = HrServiceLocator.getAccrualCategoryService() .getAccrualCategory(earnCodeObj.getAccrualCategory(), endDate); if (accrualCategory != null) { DateTime nextIntervalDate = LmServiceLocator.getAccrualService().getNextAccrualIntervalDate( accrualCategory.getAccrualEarnInterval(), endDate.toDateTimeAtStartOfDay()); // get the usage checking cut off Date, normally it's the day before the next interval date DateTime usageEndDate = nextIntervalDate; if (nextIntervalDate.compareTo(endDate.toDateTimeAtCurrentTime()) > 0) { usageEndDate = nextIntervalDate.minusDays(1); } // use the end of the year as the interval date for usage checking of no-accrual hours, // normally no-accrual hours are from banked/transferred system scheduled time offs if (accrualCategory.getAccrualEarnInterval() .equals(HrConstants.ACCRUAL_EARN_INTERVAL_CODE.NO_ACCRUAL)) { usageEndDate = endDate.toDateTimeAtStartOfDay().withMonthOfYear(DateTimeConstants.DECEMBER) .withDayOfMonth(31); } BigDecimal availableBalance = LmServiceLocator.getLeaveSummaryService() .getLeaveBalanceForAccrCatUpToDate(HrContext.getTargetPrincipalId(), startDate, endDate, accrualCategory.getAccrualCategory(), usageEndDate.toLocalDate()); if (oldAmount != null) { if (!earnCodeChanged || updatedLeaveBlock.getAccrualCategory() .equals(accrualCategory.getAccrualCategory())) { availableBalance = availableBalance.add(oldAmount.abs()); } } //multiply by days in span in case the user has also edited the start/end dates. BigDecimal desiredUsage = null; if (!HrConstants.EARN_CODE_TIME.equals(earnCodeObj.getRecordMethod())) { desiredUsage = leaveAmount.multiply(new BigDecimal(daysSpan + 1)); } else { desiredUsage = leaveAmount.multiply(new BigDecimal(daysSpan)); } if (desiredUsage.compareTo(availableBalance) > 0) { errors.add("Requested leave amount " + desiredUsage.toString() + " is greater than available leave balance " + availableBalance.toString()); //errorMessages } } } return errors; }