List of usage examples for org.joda.time LocalDate toDate
@SuppressWarnings("deprecation") public Date toDate()
java.util.Date
. From source file:org.apache.isis.objectstore.sql.jdbc.JdbcConnector.java
License:Apache License
private void addPreparedValues(final PreparedStatement statement) throws SQLException { if (queryValues.size() > 0) { int i = 1; try {//ww w.j a v a 2 s. com for (final Object value : queryValues) { if (value instanceof LocalDate) { try { statement.setObject(i, value, java.sql.Types.DATE); } catch (final SQLException e) { // TODO This daft catch is required my MySQL, which // also requires the TimeZone offset to be // "undone" final LocalDate localDate = (LocalDate) value; final int millisOffset = -DateTimeZone.getDefault().getOffset(null); final java.util.Date javaDate = localDate .toDateTimeAtStartOfDay(DateTimeZone.forOffsetMillis(millisOffset)).toDate(); statement.setObject(i, javaDate, java.sql.Types.DATE); } } else if (value instanceof InputStream) { statement.setBlob(i, (InputStream) value); } else { statement.setObject(i, value); } i++; } } catch (final SQLException e) { LOG.error("Error adding prepared value " + i + " of type " + queryValues.get(i - 1).getClass().getSimpleName(), e); throw e; } } }
From source file:org.apache.isis.runtimes.dflt.objectstores.sql.jdbc.JdbcConnector.java
License:Apache License
private void addPreparedValues(final PreparedStatement statement) throws SQLException { if (queryValues.size() > 0) { int i = 1; try {// www . j av a 2 s.c o m for (final Object value : queryValues) { if (value instanceof LocalDate) { try { statement.setObject(i, value, java.sql.Types.DATE); } catch (final SQLException e) { // TODO This daft catch is required my MySQL, which // also requires the TimeZone offset to be // "undone" final LocalDate localDate = (LocalDate) value; final int millisOffset = -DateTimeZone.getDefault().getOffset(null); final java.util.Date javaDate = localDate .toDateTimeAtStartOfDay(DateTimeZone.forOffsetMillis(millisOffset)).toDate(); statement.setObject(i, javaDate, java.sql.Types.DATE); } } else { statement.setObject(i, value); } i++; } } catch (final SQLException e) { LOG.error("Error adding prepared value " + i + " of type " + queryValues.get(i - 1).getClass().getSimpleName(), e); throw e; } } }
From source file:org.cleverbus.admin.web.msg.MessageController.java
License:Apache License
@RequestMapping(value = "/{msgId}/log", method = RequestMethod.GET) public String getLogOfMsgByMsgId(@PathVariable("msgId") Long msgId, Model model) { Message msg = messageService.findMessageById(msgId); model.addAttribute("requestMsgId", msgId); if (msg != null) { String correlationId = msg.getCorrelationId(); model.addAttribute("correlationId", correlationId); List<String> logLines = new ArrayList<String>(); try {//from ww w . j a va2s . com long start = System.currentTimeMillis(); SortedSet<LocalDate> logDates = getMsgDates(msg); logDates.add(new LocalDate()); // adding today just in case Log.debug("Starts searching log for correlationId = " + correlationId); for (LocalDate logDate : logDates) { logLines.addAll(messageLogParser.getLogLines(correlationId, logDate.toDate())); } Log.debug("Finished searching log in " + (System.currentTimeMillis() - start) + " ms."); model.addAttribute("log", StringUtils.join(logLines, "\n")); } catch (IOException ex) { model.addAttribute("logErr", "Error occurred during reading log file: " + ex.getMessage()); } } return "msgLog"; }
From source file:org.devgateway.eudevfin.projects.module.components.panels.ReportsTableListPanel.java
@Override protected void populateTable() { final ModalWindow modal = AddModalWindow(null); this.itemsListView = new ListView<ProjectReport>("projectReportsList", items) { private static final long serialVersionUID = -8758662617501215830L; @Override//from w w w .ja v a 2s . co m protected void populateItem(ListItem<ProjectReport> listItem) { final ProjectReport report = listItem.getModelObject(); AjaxLink linkToEdit = new AjaxLink("linkToEditReport") { @Override public void onClick(AjaxRequestTarget target) { PageParameters parameters = new PageParameters().add(ReportsTableModal.PARAM_REPORT_ID, report.getId()); setParameters(parameters); AddModalWindow(parameters); modal.show(target); } }; Label reportTitleLabel = new Label("reportTitle", report.getReportTitle()); String reportTypeName = new StringResourceModel(report.getType(), ReportsTableListPanel.this, null) .getString(); linkToEdit.setBody(Model.of(reportTypeName)); DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); LocalDate date = report.getFormattedReportDate() == null ? new LocalDate() : report.getFormattedReportDate(); Label reportDateLabel = new Label("reportDate", dateFormat.format(date.toDate())); LocalDate reportingPeriodStart = report.getFormattedReportingPeriodStart() == null ? new LocalDate() : report.getFormattedReportingPeriodStart(); Label reportingPeriodStartLabel = new Label("reportingPeriodStart", dateFormat.format(reportingPeriodStart.toDate())); LocalDate reportingPeriodEnd = report.getFormattedReportingPeriodEnd() == null ? new LocalDate() : report.getFormattedReportingPeriodEnd(); Label reportingPeriodEndLabel = new Label("reportingPeriodEnd", dateFormat.format(reportingPeriodEnd.toDate())); Label fileProvidedLabel = new Label("fileProvided", report.getFileProvided()); Label fileNameLabel = new Label("reportFile", report.getReportFiles().toString()); listItem.add(linkToEdit); listItem.add(reportTitleLabel); listItem.add(reportDateLabel); listItem.add(reportingPeriodStartLabel); listItem.add(reportingPeriodEndLabel); listItem.add(fileProvidedLabel); listItem.add(fileNameLabel); } }; itemsListView.setOutputMarkupId(true); this.add(modal); this.add(itemsListView); }
From source file:org.easy.scrum.model.embedded.PersistentPeriod.java
License:Apache License
public PersistentPeriod(LocalDate start, LocalDate end) { this();/* ww w. ja v a2 s . com*/ this.start = start != null ? start.toDate() : null; this.end = end != null ? end.toDate() : null; }
From source file:org.egov.tl.service.ValidityService.java
License:Open Source License
private void applyLicenseExpiryBasedOnCustomValidity(TradeLicense license, Validity validity) { LocalDate nextExpiryDate = new LocalDate(license.isNewApplication() ? license.getCommencementDate() : license.getCurrentDemand().getEgInstallmentMaster().getFromDate()); if (validity.getYear() != null && validity.getYear() > 0) nextExpiryDate = nextExpiryDate.plusYears(validity.getYear()); if (validity.getMonth() != null && validity.getMonth() > 0) nextExpiryDate = nextExpiryDate.plusMonths(validity.getMonth()); if (validity.getWeek() != null && validity.getWeek() > 0) nextExpiryDate = nextExpiryDate.plusWeeks(validity.getWeek()); if (validity.getDay() != null && validity.getDay() > 0) nextExpiryDate = nextExpiryDate.plusDays(validity.getDay()); license.setDateOfExpiry(nextExpiryDate.toDate()); }
From source file:org.fenixedu.qubdocs.ui.manage.LooseEvaluationBeanController.java
License:Open Source License
@Atomic public void createLooseEvaluation(org.fenixedu.academic.domain.Enrolment enrolment, org.joda.time.LocalDate availableDate, org.joda.time.LocalDate examDate, org.fenixedu.academic.domain.Grade grade, org.fenixedu.academic.domain.EvaluationSeason type) { final EnrolmentEvaluation evaluation = new EnrolmentEvaluation(enrolment, type); evaluation.edit(Authenticate.getUser().getPerson(), grade, availableDate.toDateTimeAtStartOfDay().toDate(), examDate.toDateTimeAtStartOfDay().toDate()); evaluation.confirmSubmission(Authenticate.getUser().getPerson(), ""); }
From source file:org.fenixedu.ulisboa.specifications.ui.evaluation.managelooseevaluation.LooseEvaluationController.java
License:Open Source License
@Atomic public void createLooseEvaluation(Enrolment enrolment, LocalDate examDate, Grade grade, LocalDate availableDate, EvaluationSeason type, ExecutionSemester improvementSemester) { final EnrolmentEvaluation evaluation = new EnrolmentEvaluation(enrolment, type); if (type.isImprovement()) { evaluation.setExecutionPeriod(improvementSemester); }/*from w ww.ja v a 2s . c o m*/ evaluation.edit(Authenticate.getUser().getPerson(), grade, availableDate.toDate(), examDate.toDateTimeAtStartOfDay().toDate()); evaluation.confirmSubmission(Authenticate.getUser().getPerson(), ""); EnrolmentServices.updateState(enrolment); CurriculumLineServices.updateAggregatorEvaluation(enrolment); EnrolmentEvaluationServices.onStateChange(evaluation); }
From source file:org.fenixedu.ulisboa.specifications.ui.firstTimeCandidacy.PersonalInformationFormController.java
License:Open Source License
@Atomic private void writeData(final ExecutionYear executionYear, final PersonalInformationForm form, final Model model) { Person person = AccessControl.getPerson(); PersonUlisboaSpecifications personUl = PersonUlisboaSpecifications.findOrCreate(person); PersonalIngressionData personalData = getOrCreatePersonalIngressionDataForCurrentExecutionYear( executionYear, getStudent(model)); if (!isPartialUpdate()) { person.setEmissionLocationOfDocumentId(form.getDocumentIdEmissionLocation()); LocalDate documentIdEmissionDate = form.getDocumentIdEmissionDate(); LocalDate documentIdExpirationDate = form.getDocumentIdExpirationDate(); person.setEmissionDateOfDocumentIdYearMonthDay( documentIdEmissionDate != null ? new YearMonthDay(documentIdEmissionDate.toDate()) : null); person.setExpirationDateOfDocumentIdYearMonthDay( documentIdExpirationDate != null ? new YearMonthDay(documentIdExpirationDate.toDate()) : null); String socialSecurityNumber = form.getSocialSecurityNumber(); if (StringUtils.isEmpty(socialSecurityNumber)) { socialSecurityNumber = FenixEduAcademicConfiguration.getConfiguration() .getDefaultSocialSecurityNumber(); }//w w w . j a va2 s. c o m person.setSocialSecurityNumber(socialSecurityNumber); } FirstTimeCandidacy candidacy = FirstTimeCandidacyController.getCandidacy(); if (candidacy != null) { if (1 < candidacy.getPlacingOption()) { personUl.setFirstOptionInstitution(form.getFirstOptionInstitution()); if (form.getFirstOptionDegreeDesignation() != null) { personUl.setFirstOptionDegreeDesignation( form.getFirstOptionDegreeDesignation().getDescription()); } } } if (!isPartialUpdate()) { if (form.getIsForeignStudent()) { person.setIdDocumentType(form.getIdDocumentType()); person.setDocumentIdNumber(form.getDocumentIdNumber()); personUl.setDgesTempIdCode(""); } } person.setCountryHighSchool(form.getCountryHighSchool()); if (person.getIdDocumentType() != null && person.getIdDocumentType() == IDDocumentType.IDENTITY_CARD && !IdentityCardUtils.validate(person.getDocumentIdNumber(), IdentityCardUtils.getDigitControlFromPerson(person))) { setIdentityCardControlNumber(person, form.getIdentificationDocumentSeriesNumber()); } }
From source file:org.flowable.dmn.engine.impl.el.util.DateUtil.java
License:Apache License
public static Date toDate(Object dateString) { if (dateString == null) { throw new IllegalArgumentException("date string cannot be empty"); }//from w ww. j a v a2 s. c o m DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyy-MM-dd"); LocalDate dateTime = dtf.parseLocalDate((String) dateString); return dateTime.toDate(); }