List of usage examples for org.joda.time LocalDateTime toDate
@SuppressWarnings("deprecation") public Date toDate()
java.util.Date
. From source file:org.apache.fineract.infrastructure.scheduledemail.service.EmailCampaignWritePlatformCommandHandlerImpl.java
License:Apache License
private void updateTriggerDates(Long campaignId) { final EmailCampaign emailCampaign = this.emailCampaignRepository.findOne(campaignId); if (emailCampaign == null) { throw new EmailCampaignNotFound(campaignId); }/*from w w w. j a va 2 s.co m*/ LocalDateTime nextTriggerDate = emailCampaign.getNextTriggerDate(); emailCampaign.setLastTriggerDate(nextTriggerDate.toDate()); //calculate new trigger date and insert into next trigger date /** * next run time has to be in the future if not calculate a new future date */ LocalDate nextRuntime = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(), emailCampaign.getNextTriggerDate().toLocalDate(), nextTriggerDate.toLocalDate()); if (nextRuntime.isBefore(DateUtils.getLocalDateOfTenant())) { // means next run time is in the past calculate a new future date nextRuntime = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(), emailCampaign.getNextTriggerDate().toLocalDate(), DateUtils.getLocalDateOfTenant()); } final LocalDateTime getTime = emailCampaign.getRecurrenceStartDateTime(); final String dateString = nextRuntime.toString() + " " + getTime.getHourOfDay() + ":" + getTime.getMinuteOfHour() + ":" + getTime.getSecondOfMinute(); final DateTimeFormatter simpleDateFormat = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); final LocalDateTime newTriggerDateWithTime = LocalDateTime.parse(dateString, simpleDateFormat); emailCampaign.setNextTriggerDate(newTriggerDateWithTime.toDate()); this.emailCampaignRepository.saveAndFlush(emailCampaign); }
From source file:org.apache.fineract.infrastructure.scheduledemail.service.EmailCampaignWritePlatformCommandHandlerImpl.java
License:Apache License
@Transactional @Override/* w ww .j a v a 2 s .c o m*/ public CommandProcessingResult activateEmailCampaign(Long campaignId, JsonCommand command) { final AppUser currentUser = this.context.authenticatedUser(); this.emailCampaignValidator.validateActivation(command.json()); final EmailCampaign emailCampaign = this.emailCampaignRepository.findOne(campaignId); if (emailCampaign == null) { throw new EmailCampaignNotFound(campaignId); } final Locale locale = command.extractLocale(); final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale); final LocalDate activationDate = command.localDateValueOfParameterNamed("activationDate"); emailCampaign.activate(currentUser, fmt, activationDate); this.emailCampaignRepository.saveAndFlush(emailCampaign); if (emailCampaign.isDirect()) { insertDirectCampaignIntoEmailOutboundTable(emailCampaign.getParamValue(), emailCampaign.getEmailSubject(), emailCampaign.getEmailMessage(), emailCampaign.getCampaignName(), emailCampaign.getId()); } else { if (emailCampaign.isSchedule()) { /** * if recurrence start date is in the future calculate * next trigger date if not use recurrence start date us next trigger * date when activating */ LocalDate nextTriggerDate = null; if (emailCampaign.getRecurrenceStartDateTime().isBefore(tenantDateTime())) { nextTriggerDate = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(), emailCampaign.getRecurrenceStartDate(), DateUtils.getLocalDateOfTenant()); } else { nextTriggerDate = emailCampaign.getRecurrenceStartDate(); } // to get time of tenant final LocalDateTime getTime = emailCampaign.getRecurrenceStartDateTime(); final String dateString = nextTriggerDate.toString() + " " + getTime.getHourOfDay() + ":" + getTime.getMinuteOfHour() + ":" + getTime.getSecondOfMinute(); final DateTimeFormatter simpleDateFormat = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); final LocalDateTime nextTriggerDateWithTime = LocalDateTime.parse(dateString, simpleDateFormat); emailCampaign.setNextTriggerDate(nextTriggerDateWithTime.toDate()); this.emailCampaignRepository.saveAndFlush(emailCampaign); } } /* if campaign is direct insert campaign message into scheduledemail outbound table else if its a schedule create a job process for it */ return new CommandProcessingResultBuilder() // .withCommandId(command.commandId()) // .withEntityId(emailCampaign.getId()) // .build(); }
From source file:org.apache.fineract.infrastructure.scheduledemail.service.EmailCampaignWritePlatformCommandHandlerImpl.java
License:Apache License
@Transactional @Override//from w w w. j a v a2 s . c o m public CommandProcessingResult reactivateEmailCampaign(final Long campaignId, JsonCommand command) { this.emailCampaignValidator.validateActivation(command.json()); final AppUser currentUser = this.context.authenticatedUser(); final EmailCampaign emailCampaign = this.emailCampaignRepository.findOne(campaignId); if (emailCampaign == null) { throw new EmailCampaignNotFound(campaignId); } final Locale locale = command.extractLocale(); final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale); final LocalDate reactivationDate = command.localDateValueOfParameterNamed("activationDate"); emailCampaign.reactivate(currentUser, fmt, reactivationDate); if (emailCampaign.isSchedule()) { /** * if recurrence start date is in the future calculate * next trigger date if not use recurrence start date us next trigger date when activating */ LocalDate nextTriggerDate = null; if (emailCampaign.getRecurrenceStartDateTime().isBefore(tenantDateTime())) { nextTriggerDate = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(), emailCampaign.getRecurrenceStartDate(), DateUtils.getLocalDateOfTenant()); } else { nextTriggerDate = emailCampaign.getRecurrenceStartDate(); } // to get time of tenant final LocalDateTime getTime = emailCampaign.getRecurrenceStartDateTime(); final String dateString = nextTriggerDate.toString() + " " + getTime.getHourOfDay() + ":" + getTime.getMinuteOfHour() + ":" + getTime.getSecondOfMinute(); final DateTimeFormatter simpleDateFormat = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); final LocalDateTime nextTriggerDateWithTime = LocalDateTime.parse(dateString, simpleDateFormat); emailCampaign.setNextTriggerDate(nextTriggerDateWithTime.toDate()); this.emailCampaignRepository.saveAndFlush(emailCampaign); } return new CommandProcessingResultBuilder() // .withEntityId(emailCampaign.getId()) // .build(); }
From source file:org.apache.fineract.infrastructure.sms.domain.SmsCampaign.java
License:Apache License
private SmsCampaign(final String campaignName, final Integer campaignType, final Report businessRuleId, final String paramValue, final String message, final LocalDate submittedOnDate, final AppUser submittedBy, final String recurrence, final LocalDateTime localDateTime) { this.campaignName = campaignName; this.campaignType = SmsCampaignType.fromInt(campaignType).getValue(); this.businessRuleId = businessRuleId; this.paramValue = paramValue; this.status = SmsCampaignStatus.PENDING.getValue(); this.message = message; this.submittedOnDate = submittedOnDate.toDate(); this.submittedBy = submittedBy; this.recurrence = recurrence; LocalDateTime recurrenceStartDate = new LocalDateTime(); this.isVisible = true; if (localDateTime != null) { this.recurrenceStartDate = localDateTime.toDate(); } else {/*from www . jav a 2s. c o m*/ this.recurrenceStartDate = recurrenceStartDate.toDate(); } }
From source file:org.apache.fineract.infrastructure.sms.service.SmsCampaignWritePlatformCommandHandlerImpl.java
License:Apache License
private void updateTriggerDates(Long campaignId) { final SmsCampaign smsCampaign = this.smsCampaignRepository.findOne(campaignId); if (smsCampaign == null) { throw new SmsCampaignNotFound(campaignId); }//from w w w .ja va 2 s .c om LocalDateTime nextTriggerDate = smsCampaign.getNextTriggerDate(); smsCampaign.setLastTriggerDate(nextTriggerDate.toDate()); //calculate new trigger date and insert into next trigger date /** * next run time has to be in the future if not calculate a new future date */ LocalDate nextRuntime = CalendarUtils.getNextRecurringDate(smsCampaign.getRecurrence(), smsCampaign.getNextTriggerDate().toLocalDate(), nextTriggerDate.toLocalDate()); if (nextRuntime.isBefore(DateUtils.getLocalDateOfTenant())) { // means next run time is in the past calculate a new future date nextRuntime = CalendarUtils.getNextRecurringDate(smsCampaign.getRecurrence(), smsCampaign.getNextTriggerDate().toLocalDate(), DateUtils.getLocalDateOfTenant()); } final LocalDateTime getTime = smsCampaign.getRecurrenceStartDateTime(); final String dateString = nextRuntime.toString() + " " + getTime.getHourOfDay() + ":" + getTime.getMinuteOfHour() + ":" + getTime.getSecondOfMinute(); final DateTimeFormatter simpleDateFormat = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); final LocalDateTime newTriggerDateWithTime = LocalDateTime.parse(dateString, simpleDateFormat); smsCampaign.setNextTriggerDate(newTriggerDateWithTime.toDate()); this.smsCampaignRepository.saveAndFlush(smsCampaign); }
From source file:org.apache.fineract.infrastructure.sms.service.SmsCampaignWritePlatformCommandHandlerImpl.java
License:Apache License
@Transactional @Override// ww w .j a va2 s. co m public CommandProcessingResult activateSmsCampaign(Long campaignId, JsonCommand command) { final AppUser currentUser = this.context.authenticatedUser(); this.smsCampaignValidator.validateActivation(command.json()); final SmsCampaign smsCampaign = this.smsCampaignRepository.findOne(campaignId); if (smsCampaign == null) { throw new SmsCampaignNotFound(campaignId); } final Locale locale = command.extractLocale(); final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale); final LocalDate activationDate = command.localDateValueOfParameterNamed("activationDate"); smsCampaign.activate(currentUser, fmt, activationDate); this.smsCampaignRepository.saveAndFlush(smsCampaign); if (smsCampaign.isDirect()) { insertDirectCampaignIntoSmsOutboundTable(smsCampaign.getParamValue(), smsCampaign.getMessage(), smsCampaign.getCampaignName()); } else { if (smsCampaign.isSchedule()) { /** * if recurrence start date is in the future calculate * next trigger date if not use recurrence start date us next trigger * date when activating */ LocalDate nextTriggerDate = null; if (smsCampaign.getRecurrenceStartDateTime().isBefore(tenantDateTime())) { nextTriggerDate = CalendarUtils.getNextRecurringDate(smsCampaign.getRecurrence(), smsCampaign.getRecurrenceStartDate(), DateUtils.getLocalDateOfTenant()); } else { nextTriggerDate = smsCampaign.getRecurrenceStartDate(); } // to get time of tenant final LocalDateTime getTime = smsCampaign.getRecurrenceStartDateTime(); final String dateString = nextTriggerDate.toString() + " " + getTime.getHourOfDay() + ":" + getTime.getMinuteOfHour() + ":" + getTime.getSecondOfMinute(); final DateTimeFormatter simpleDateFormat = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); final LocalDateTime nextTriggerDateWithTime = LocalDateTime.parse(dateString, simpleDateFormat); smsCampaign.setNextTriggerDate(nextTriggerDateWithTime.toDate()); this.smsCampaignRepository.saveAndFlush(smsCampaign); } } /* if campaign is direct insert campaign message into sms outbound table else if its a schedule create a job process for it */ return new CommandProcessingResultBuilder() // .withCommandId(command.commandId()) // .withEntityId(smsCampaign.getId()) // .build(); }
From source file:org.apache.fineract.infrastructure.sms.service.SmsCampaignWritePlatformCommandHandlerImpl.java
License:Apache License
@Transactional @Override/*from w w w.j av a2s.c om*/ public CommandProcessingResult reactivateSmsCampaign(final Long campaignId, JsonCommand command) { this.smsCampaignValidator.validateActivation(command.json()); final AppUser currentUser = this.context.authenticatedUser(); final SmsCampaign smsCampaign = this.smsCampaignRepository.findOne(campaignId); if (smsCampaign == null) { throw new SmsCampaignNotFound(campaignId); } final Locale locale = command.extractLocale(); final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale); final LocalDate reactivationDate = command.localDateValueOfParameterNamed("activationDate"); smsCampaign.reactivate(currentUser, fmt, reactivationDate); if (smsCampaign.isSchedule()) { /** * if recurrence start date is in the future calculate * next trigger date if not use recurrence start date us next trigger * date when activating */ LocalDate nextTriggerDate = null; if (smsCampaign.getRecurrenceStartDateTime().isBefore(tenantDateTime())) { nextTriggerDate = CalendarUtils.getNextRecurringDate(smsCampaign.getRecurrence(), smsCampaign.getRecurrenceStartDate(), DateUtils.getLocalDateOfTenant()); } else { nextTriggerDate = smsCampaign.getRecurrenceStartDate(); } // to get time of tenant final LocalDateTime getTime = smsCampaign.getRecurrenceStartDateTime(); final String dateString = nextTriggerDate.toString() + " " + getTime.getHourOfDay() + ":" + getTime.getMinuteOfHour() + ":" + getTime.getSecondOfMinute(); final DateTimeFormatter simpleDateFormat = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); final LocalDateTime nextTriggerDateWithTime = LocalDateTime.parse(dateString, simpleDateFormat); smsCampaign.setNextTriggerDate(nextTriggerDateWithTime.toDate()); this.smsCampaignRepository.saveAndFlush(smsCampaign); } return new CommandProcessingResultBuilder() // .withEntityId(smsCampaign.getId()) // .build(); }
From source file:org.codeqinvest.codechanges.scm.svn.DefaultSvnRevisionsRetriever.java
License:Open Source License
/** * {@inheritDoc}//from www . java2 s . c o m */ @Override @Cacheable("svnRevisions") public DailyRevisions retrieveRevisions(ScmConnectionSettings connectionSettings, LocalDate day) throws SVNException { log.info("Retrieve revisions on day {} for {}", day, connectionSettings); final SVNRepository repository = SvnRepositoryFactory.create(connectionSettings); final LocalDateTime startTime = day.toDateTimeAtStartOfDay().toLocalDateTime(); final long startRevision = repository.getDatedRevision(startTime.toDate()); final long endRevision = repository.getDatedRevision(startTime.withTime(23, 59, 59, 999).toDate()); final Multimap<String, SvnFileRevision> revisions = ArrayListMultimap.create(); repository.log(null, startRevision, endRevision, true, true, new ISVNLogEntryHandler() { @Override public void handleLogEntry(SVNLogEntry logEntry) throws SVNException { for (SVNLogEntryPath logEntryPath : logEntry.getChangedPaths().values()) { if (logEntryPath.getCopyPath() != null) { revisions.put(logEntryPath.getPath(), new SvnFileRevision(logEntry.getRevision(), logEntryPath.getCopyPath(), logEntryPath.getPath())); } else { revisions.put(logEntryPath.getPath(), new SvnFileRevision(logEntry.getRevision(), logEntryPath.getPath(), logEntryPath.getPath())); } } } }); log.info("Found {} changes for day {} with connection {}", revisions.values().size(), day, connectionSettings); return new DailyRevisions(day, revisions); }
From source file:org.datanucleus.store.types.jodatime.converters.JodaLocalDateTimeTimestampConverter.java
License:Open Source License
public Timestamp toDatastoreType(LocalDateTime ldt) { if (ldt == null) { return null; }//from ww w .ja v a 2 s . c o m return new Timestamp(ldt.toDate().getTime()); }
From source file:org.devgateway.eudevfin.ui.common.models.DateToLocalDateTimeModel.java
License:Open Source License
@Override public Date getObject() { LocalDateTime date = originalModel.getObject(); return (date == null ? null : date.toDate()); }