List of usage examples for org.joda.time LocalDateTime LocalDateTime
public LocalDateTime()
From source file:org.kitodo.services.data.UserService.java
License:Open Source License
/** * Add filter to user.// ww w . j a v a2s . co m * * @param user * object * @param userFilter * String */ private void addFilterToUser(User user, String userFilter) throws DataException { LocalDateTime localDateTime = new LocalDateTime(); Filter filter = new Filter(); filter.setValue(userFilter); filter.setCreationDate(localDateTime.toDate()); filter.setUser(user); serviceManager.getFilterService().save(filter); refresh(user); }
From source file:org.mifos.application.servicefacade.LoginServiceFacadeWebTier.java
License:Open Source License
@Override public void changePassword(ChangePasswordRequest changePasswordRequest) { PersonnelBO user = this.personnelDao.findPersonnelByUsername(changePasswordRequest.getUsername()); this.personnelService.changePassword(user, changePasswordRequest.getNewPassword(), true); Date newExpirationDate = null; if (user.getPasswordExpirationDate() != null) { newExpirationDate = new LocalDateTime().plusDays(PasswordRules.getPasswordExpirationDatePrelongation()) .toDateTime().toDate();//from w w w . j ava 2 s .c o m } personnelService.changePasswordExpirationDate(user, newExpirationDate); }
From source file:org.mifos.application.servicefacade.LoginServiceFacadeWebTier.java
License:Open Source License
@Override public boolean updatePassword(String username, String oldPassword, String newPassword) { MifosUser appUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); UserContext userContext = new UserContextFactory().create(appUser); PersonnelBO user = this.personnelDao.findPersonnelByUsername(username); boolean passwordIsAlreadyChanged = user.isPasswordChanged(); this.personnelService.changePassword(user, newPassword, true); Date newExpirationDate = null; if (user.getPasswordExpirationDate() != null) { newExpirationDate = new LocalDateTime().plusDays(PasswordRules.getPasswordExpirationDatePrelongation()) .toDateTime().toDate();/*from w w w .j a v a 2 s . c o m*/ } personnelService.changePasswordExpirationDate(user, newExpirationDate); return passwordIsAlreadyChanged; }
From source file:org.mifos.customers.personnel.business.service.PersonnelServiceImpl.java
License:Open Source License
@Override public void changePassword(PersonnelBO user, String newPassword, boolean setPasswordChanged) { UserContext userContext = new UserContext(); userContext.setId(user.getPersonnelId()); userContext.setName(user.getUserName()); user.updateDetails(userContext);/* ww w . ja v a 2 s . com*/ validateIfPasswordIsRecentlyUsed(user, newPassword); byte[] newEncPass = EncryptionService.getInstance().createEncryptedPassword(newPassword); PersonnelUsedPasswordEntity personnelUsedPassword; int passwordHistoryCount = PasswordRules.getPasswordHistoryCount(); if (user.getPersonnelUsedPasswords().size() >= passwordHistoryCount) { personnelUsedPassword = new ArrayList<PersonnelUsedPasswordEntity>(user.getPersonnelUsedPasswords()) .get(0); personnelUsedPassword.setUsedPassword(newEncPass); personnelUsedPassword.setDateChanged(new LocalDateTime().toDateTime().toDate()); } else { personnelUsedPassword = new PersonnelUsedPasswordEntity(); personnelUsedPassword.setPersonnel(user); personnelUsedPassword.setUsedPassword(newEncPass); personnelUsedPassword.setDateChanged(new LocalDateTime().toDateTime().toDate()); user.getPersonnelUsedPasswords().add(personnelUsedPassword); } try { hibernateTransactionHelper.startTransaction(); hibernateTransactionHelper.beginAuditLoggingFor(user); user.changePasswordTo(newPassword, user.getPersonnelId(), setPasswordChanged); this.personnelDao.save(user); hibernateTransactionHelper.commitTransaction(); } catch (Exception e) { hibernateTransactionHelper.rollbackTransaction(); throw new MifosRuntimeException(e); } finally { hibernateTransactionHelper.closeSession(); } }
From source file:org.mifosplatform.infrastructure.reportmailingjob.domain.ReportMailingJob.java
License:Mozilla Public License
/** * create a new instance of the ReportmailingJob for a new entry * /*from w w w.j av a 2 s.c o m*/ * @return ReportMailingJob object **/ public static ReportMailingJob instance(JsonCommand jsonCommand, final Report stretchyReport, final LocalDate createdOnDate, final AppUser createdByUser, final AppUser runAsUser) { final String name = jsonCommand.stringValueOfParameterNamed(ReportMailingJobConstants.NAME_PARAM_NAME); final String description = jsonCommand .stringValueOfParameterNamed(ReportMailingJobConstants.DESCRIPTION_PARAM_NAME); final String recurrence = jsonCommand .stringValueOfParameterNamed(ReportMailingJobConstants.RECURRENCE_PARAM_NAME); final boolean isActive = jsonCommand .booleanPrimitiveValueOfParameterNamed(ReportMailingJobConstants.IS_ACTIVE_PARAM_NAME); final String emailRecipients = jsonCommand .stringValueOfParameterNamed(ReportMailingJobConstants.EMAIL_RECIPIENTS_PARAM_NAME); final String emailSubject = jsonCommand .stringValueOfParameterNamed(ReportMailingJobConstants.EMAIL_SUBJECT_PARAM_NAME); final String emailMessage = jsonCommand .stringValueOfParameterNamed(ReportMailingJobConstants.EMAIL_MESSAGE_PARAM_NAME); final String stretchyReportParamMap = jsonCommand .stringValueOfParameterNamed(ReportMailingJobConstants.STRETCHY_REPORT_PARAM_MAP_PARAM_NAME); final Integer emailAttachmentFileFormatId = jsonCommand .integerValueOfParameterNamed(ReportMailingJobConstants.EMAIL_ATTACHMENT_FILE_FORMAT_ID_PARAM_NAME); final ReportMailingJobEmailAttachmentFileFormat emailAttachmentFileFormat = ReportMailingJobEmailAttachmentFileFormat .instance(emailAttachmentFileFormatId); LocalDateTime startDateTime = new LocalDateTime(); if (jsonCommand.hasParameter(ReportMailingJobConstants.START_DATE_TIME_PARAM_NAME)) { final String startDateTimeString = jsonCommand .stringValueOfParameterNamed(ReportMailingJobConstants.START_DATE_TIME_PARAM_NAME); if (startDateTimeString != null) { final DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(jsonCommand.dateFormat()) .withLocale(jsonCommand.extractLocale()); startDateTime = LocalDateTime.parse(startDateTimeString, dateTimeFormatter); } } return new ReportMailingJob(name, description, startDateTime, recurrence, createdOnDate, createdByUser, emailRecipients, emailSubject, emailMessage, emailAttachmentFileFormat, stretchyReport, stretchyReportParamMap, null, startDateTime, null, null, null, isActive, false, runAsUser); }
From source file:org.mifosplatform.infrastructure.scheduledemail.service.EmailCampaignWritePlatformCommandHandlerImpl.java
License:Mozilla Public License
private LocalDateTime tenantDateTime() { LocalDateTime today = new LocalDateTime(); final MifosPlatformTenant tenant = ThreadLocalContextUtil.getTenant(); if (tenant != null) { final DateTimeZone zone = DateTimeZone.forID(tenant.getTimezoneId()); if (zone != null) { today = new LocalDateTime(zone); }//w w w .ja v a 2 s . c o m } return today; }
From source file:org.netxilia.functions.DateFunctions.java
License:Open Source License
@Function(cacheable = false) public ReadablePartial NOW() { return new LocalDateTime(); }
From source file:org.odk.collect.android.fragments.dialogs.BikramSambatDatePickerDialog.java
License:Apache License
@Override protected LocalDateTime getOriginalDate() { BsGregorianDate bsGregorianDate = null; try {/* w w w. j ava 2 s. c o m*/ bsGregorianDate = BsCalendar.getInstance().toGreg( new BikramSambatDate(getYear(), Arrays.asList(monthsArray).indexOf(getMonth()) + 1, getDay())); } catch (BsException e) { Timber.e(e); } return new LocalDateTime().withYear(bsGregorianDate.year).withMonthOfYear(bsGregorianDate.month) .withDayOfMonth(bsGregorianDate.day).withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0) .withMillisOfSecond(0); }
From source file:org.ohmage.mobility.activity.ActivityRecognitionIntentService.java
License:Apache License
/** * Write the activity recognition update to the log file * * @param result The result extracted from the incoming Intent *//* ww w . ja v a 2 s . co m*/ private void logActivityRecognitionResult(ActivityRecognitionResult result) { StringBuilder msg = new StringBuilder(DateTimeFormat.mediumDateTime().print(new LocalDateTime())); // Get all the probably activities from the updated result for (DetectedActivity detectedActivity : result.getProbableActivities()) { // Get the activity type, confidence level, and human-readable name int activityType = detectedActivity.getType(); int confidence = detectedActivity.getConfidence(); String activityName = getNameFromType(activityType); msg.append("|").append(activityName).append(": ").append(confidence); } ContentValues values = new ContentValues(); values.put(MobilityContentProvider.ActivityPoint.DATA, msg.toString()); getContentResolver().insert(MobilityContentProvider.ActivityPoint.CONTENT_URI, values); }
From source file:org.ohmage.mobility.location.LocationListenerIntentService.java
License:Apache License
/** * Write the location update to the log file * * @param result The result extracted from the incoming Intent *///from w w w .ja va 2 s .c o m private void logLocationResult(Location result) { StringBuilder msg = new StringBuilder(DateTimeFormat.mediumDateTime().print(new LocalDateTime())) .append("|"); msg.append(result.getLatitude()).append(", ").append(result.getLongitude()); ContentValues values = new ContentValues(); values.put(MobilityContentProvider.LocationPoint.DATA, msg.toString()); getContentResolver().insert(MobilityContentProvider.LocationPoint.CONTENT_URI, values); }