List of usage examples for org.joda.time LocalDateTime toDate
@SuppressWarnings("deprecation") public Date toDate()
java.util.Date
. From source file:org.kitodo.services.data.UserService.java
License:Open Source License
/** * Add filter to user.//from w ww. j av a 2 s . 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.kuali.student.r2.common.dto.TimeOfDayInfo.java
License:Educational Community License
/** * * @param date a java.util.Date to which timeOfDay is added (the hours, minutes, seconds * and milliseconds are ignored and treated as 0. Only the month, day, year * of date is relevant)/*from w ww. ja va 2s . c o m*/ * @param timeOfDay the TimeOfDay that is added to the date parameter * @return a java.util.Date that is the sum of date and timeOfDay */ public static Date getDateWithTimeOfDay(Date date, TimeOfDay timeOfDay) { if (date == null || timeOfDay == null) { return null; } // This is JODA which is the preferred way to deal with time. // One issue: Java's Date class doesn't have a way to store the timezone associated with the date. // Instead, it saves millis since Jan 1, 1970 (GMT), and uses the local machine's timezone to // interpret it (although, it can also handle UTC as a timezone). To store the timezone, you either // need Joda's LocalDateTime or use the Calendar class. Thus, it is recommended that you either // pass in the date relative to the current timezone, or perhaps redo this class where you pass // a timezone in, and don't use a Date class, but use a Joda DateTime class. --cclin LocalDateTime time = new LocalDateTime(date); LocalDateTime result = new LocalDateTime(time.getYear(), time.getMonthOfYear(), time.getDayOfMonth(), timeOfDay.getHour() == null ? 0 : timeOfDay.getHour(), timeOfDay.getMinute() == null ? 0 : timeOfDay.getMinute(), timeOfDay.getSecond() == null ? 0 : timeOfDay.getSecond(), 0); return result.toDate(); }
From source file:org.kzac.common.dto.TimeOfDayInfo.java
License:Educational Community License
/** * //from ww w. j a va 2 s. c o m * @param date * a java.util.Date to which timeOfDay is added (the hours, * minutes, seconds and milliseconds are ignored and treated as * 0. Only the month, day, year of date is relevant) * @param timeOfDay * the TimeOfDay that is added to the date parameter * @return a java.util.Date that is the sum of date and timeOfDay */ public static Date getDateWithTimeOfDay(Date date, TimeOfDay timeOfDay) { if (date == null || timeOfDay == null) { return null; } // This is JODA which is the preferred way to deal with time. // One issue: Java's Date class doesn't have a way to store the timezone // associated with the date. // Instead, it saves millis since Jan 1, 1970 (GMT), and uses the local // machine's timezone to // interpret it (although, it can also handle UTC as a timezone). To // store the timezone, you either // need Joda's LocalDateTime or use the Calendar class. Thus, it is // recommended that you either // pass in the date relative to the current timezone, or perhaps redo // this class where you pass // a timezone in, and don't use a Date class, but use a Joda DateTime // class. --cclin LocalDateTime time = new LocalDateTime(date); LocalDateTime result = new LocalDateTime(time.getYear(), time.getMonthOfYear(), time.getDayOfMonth(), timeOfDay.getHour() == null ? 0 : timeOfDay.getHour(), timeOfDay.getMinute() == null ? 0 : timeOfDay.getMinute(), timeOfDay.getSecond() == null ? 0 : timeOfDay.getSecond(), 0); return result.toDateTime().toDate(); }
From source file:org.mifosplatform.infrastructure.reportmailingjob.domain.ReportMailingJob.java
License:Mozilla Public License
/** * ReportMailingJob private constructor **//*from w ww .j av a 2 s. c o m*/ private ReportMailingJob(final String name, final String description, final LocalDateTime startDateTime, final String recurrence, final LocalDate createdOnDate, final AppUser createdByUser, final String emailRecipients, final String emailSubject, final String emailMessage, final ReportMailingJobEmailAttachmentFileFormat emailAttachmentFileFormat, final Report stretchyReport, final String stretchyReportParamMap, final LocalDateTime previousRunDateTime, final LocalDateTime nextRunDateTime, final ReportMailingJobPreviousRunStatus previousRunStatus, final String previousRunErrorLog, final String previousRunErrorMessage, final boolean isActive, final boolean isDeleted, final AppUser runAsUser) { this.name = name; this.description = description; this.startDateTime = null; if (startDateTime != null) { this.startDateTime = startDateTime.toDate(); } this.recurrence = recurrence; this.createdOnDate = null; if (createdOnDate != null) { this.createdOnDate = createdOnDate.toDate(); } this.createdByUser = createdByUser; this.emailRecipients = emailRecipients; this.emailSubject = emailSubject; this.emailMessage = emailMessage; this.emailAttachmentFileFormat = emailAttachmentFileFormat.getValue(); this.stretchyReport = stretchyReport; this.stretchyReportParamMap = stretchyReportParamMap; this.previousRunDateTime = null; if (previousRunDateTime != null) { this.previousRunDateTime = previousRunDateTime.toDate(); } this.nextRunDateTime = null; if (nextRunDateTime != null) { this.nextRunDateTime = nextRunDateTime.toDate(); } this.previousRunStatus = null; if (previousRunStatus != null) { this.previousRunStatus = previousRunStatus.getValue(); } if (numberOfRuns == null) { this.numberOfRuns = 0; } this.previousRunErrorLog = previousRunErrorLog; this.previousRunErrorMessage = previousRunErrorMessage; this.isActive = isActive; this.isDeleted = isDeleted; this.runAsUser = runAsUser; }
From source file:org.mifosplatform.infrastructure.reportmailingjob.domain.ReportMailingJob.java
License:Mozilla Public License
/** * Update the ReportMailingJob entity // w w w .ja v a2s . co m * * @param jsonCommand JsonCommand object * @return map of string to object **/ public Map<String, Object> update(final JsonCommand jsonCommand) { final Map<String, Object> actualChanges = new LinkedHashMap<>(); if (jsonCommand.isChangeInStringParameterNamed(ReportMailingJobConstants.NAME_PARAM_NAME, this.name)) { final String name = jsonCommand.stringValueOfParameterNamed(ReportMailingJobConstants.NAME_PARAM_NAME); actualChanges.put(ReportMailingJobConstants.NAME_PARAM_NAME, name); this.name = name; } if (jsonCommand.isChangeInStringParameterNamed(ReportMailingJobConstants.DESCRIPTION_PARAM_NAME, this.description)) { final String description = jsonCommand .stringValueOfParameterNamed(ReportMailingJobConstants.DESCRIPTION_PARAM_NAME); actualChanges.put(ReportMailingJobConstants.DESCRIPTION_PARAM_NAME, description); this.description = description; } if (jsonCommand.isChangeInStringParameterNamed(ReportMailingJobConstants.RECURRENCE_PARAM_NAME, this.recurrence)) { final String recurrence = jsonCommand .stringValueOfParameterNamed(ReportMailingJobConstants.RECURRENCE_PARAM_NAME); actualChanges.put(ReportMailingJobConstants.RECURRENCE_PARAM_NAME, recurrence); this.recurrence = recurrence; } if (jsonCommand.isChangeInBooleanParameterNamed(ReportMailingJobConstants.IS_ACTIVE_PARAM_NAME, this.isActive)) { final boolean isActive = jsonCommand .booleanPrimitiveValueOfParameterNamed(ReportMailingJobConstants.IS_ACTIVE_PARAM_NAME); actualChanges.put(ReportMailingJobConstants.IS_ACTIVE_PARAM_NAME, isActive); this.isActive = isActive; } if (jsonCommand.isChangeInStringParameterNamed(ReportMailingJobConstants.EMAIL_RECIPIENTS_PARAM_NAME, this.emailRecipients)) { final String emailRecipients = jsonCommand .stringValueOfParameterNamed(ReportMailingJobConstants.EMAIL_RECIPIENTS_PARAM_NAME); actualChanges.put(ReportMailingJobConstants.EMAIL_RECIPIENTS_PARAM_NAME, emailRecipients); this.emailRecipients = emailRecipients; } if (jsonCommand.isChangeInStringParameterNamed(ReportMailingJobConstants.EMAIL_SUBJECT_PARAM_NAME, this.emailSubject)) { final String emailSubject = jsonCommand .stringValueOfParameterNamed(ReportMailingJobConstants.EMAIL_SUBJECT_PARAM_NAME); actualChanges.put(ReportMailingJobConstants.EMAIL_SUBJECT_PARAM_NAME, emailSubject); this.emailSubject = emailSubject; } if (jsonCommand.isChangeInStringParameterNamed(ReportMailingJobConstants.EMAIL_MESSAGE_PARAM_NAME, this.emailMessage)) { final String emailMessage = jsonCommand .stringValueOfParameterNamed(ReportMailingJobConstants.EMAIL_MESSAGE_PARAM_NAME); actualChanges.put(ReportMailingJobConstants.EMAIL_MESSAGE_PARAM_NAME, emailMessage); this.emailMessage = emailMessage; } if (jsonCommand.isChangeInStringParameterNamed( ReportMailingJobConstants.STRETCHY_REPORT_PARAM_MAP_PARAM_NAME, this.stretchyReportParamMap)) { final String stretchyReportParamMap = jsonCommand .stringValueOfParameterNamed(ReportMailingJobConstants.STRETCHY_REPORT_PARAM_MAP_PARAM_NAME); actualChanges.put(ReportMailingJobConstants.STRETCHY_REPORT_PARAM_MAP_PARAM_NAME, stretchyReportParamMap); this.stretchyReportParamMap = stretchyReportParamMap; } final ReportMailingJobEmailAttachmentFileFormat emailAttachmentFileFormat = ReportMailingJobEmailAttachmentFileFormat .instance(this.emailAttachmentFileFormat); if (jsonCommand.isChangeInIntegerParameterNamed( ReportMailingJobConstants.EMAIL_ATTACHMENT_FILE_FORMAT_ID_PARAM_NAME, emailAttachmentFileFormat.getId())) { final Integer emailAttachmentFileFormatId = jsonCommand.integerValueOfParameterNamed( ReportMailingJobConstants.EMAIL_ATTACHMENT_FILE_FORMAT_ID_PARAM_NAME); actualChanges.put(ReportMailingJobConstants.EMAIL_ATTACHMENT_FILE_FORMAT_ID_PARAM_NAME, emailAttachmentFileFormatId); final ReportMailingJobEmailAttachmentFileFormat newEmailAttachmentFileFormat = ReportMailingJobEmailAttachmentFileFormat .instance(emailAttachmentFileFormatId); this.emailAttachmentFileFormat = newEmailAttachmentFileFormat.getValue(); } final String newStartDateTimeString = jsonCommand .stringValueOfParameterNamed(ReportMailingJobConstants.START_DATE_TIME_PARAM_NAME); if (!StringUtils.isEmpty(newStartDateTimeString)) { final DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(jsonCommand.dateFormat()) .withLocale(jsonCommand.extractLocale()); final LocalDateTime newStartDateTime = LocalDateTime.parse(newStartDateTimeString, dateTimeFormatter); final LocalDateTime oldStartDateTime = (this.startDateTime != null) ? new LocalDateTime(this.startDateTime) : null; if ((oldStartDateTime != null) && !newStartDateTime.equals(oldStartDateTime)) { actualChanges.put(ReportMailingJobConstants.START_DATE_TIME_PARAM_NAME, newStartDateTimeString); this.startDateTime = newStartDateTime.toDate(); } } Long currentStretchyReportId = null; if (this.stretchyReport != null) { currentStretchyReportId = this.stretchyReport.getId(); } if (jsonCommand.isChangeInLongParameterNamed(ReportMailingJobConstants.STRETCHY_REPORT_ID_PARAM_NAME, currentStretchyReportId)) { final Long updatedStretchyReportId = jsonCommand .longValueOfParameterNamed(ReportMailingJobConstants.STRETCHY_REPORT_ID_PARAM_NAME); actualChanges.put(ReportMailingJobConstants.STRETCHY_REPORT_ID_PARAM_NAME, updatedStretchyReportId); } return actualChanges; }
From source file:org.openmrs.module.referencedemodata.ReferenceDemoDataActivator.java
License:Open Source License
private Visit createDemoVisit(Patient patient, List<VisitType> visitTypes, Location location, boolean shortVisit) { LocalDateTime visitStart = LocalDateTime.now().minus(Period.days(randomBetween(0, 365 * 2)).withHours(3)); // past 2 years if (!shortVisit) { visitStart = visitStart.minus(Period.days(ADMISSION_DAYS_MAX + 1)); // just in case the start is today, back it up a few days. }/*from w w w. j ava 2s .c o m*/ Visit visit = new Visit(patient, randomArrayEntry(visitTypes), visitStart.toDate()); visit.setLocation(location); LocalDateTime vitalsTime = visitStart.plus(Period.minutes(randomBetween(1, 60))); visit.addEncounter(createDemoVitalsEncounter(patient, vitalsTime.toDate())); LocalDateTime visitNoteTime = visitStart.plus(Period.minutes(randomBetween(60, 120))); visit.addEncounter(createVisitNote(patient, visitNoteTime.toDate(), location)); if (shortVisit) { LocalDateTime visitEndTime = visitNoteTime.plus(Period.minutes(30)); visit.setStopDatetime(visitEndTime.toDate()); } else { // admit now and discharge a few days later Location admitLocation = Context.getLocationService().getLocation("Inpatient Ward"); visit.addEncounter(createEncounter("Admission", patient, visitNoteTime.toDate(), admitLocation)); LocalDateTime dischargeDateTime = visitNoteTime .plus(Period.days(randomBetween(ADMISSION_DAYS_MIN, ADMISSION_DAYS_MAX))); visit.addEncounter(createEncounter("Discharge", patient, dischargeDateTime.toDate(), admitLocation)); visit.setStopDatetime(dischargeDateTime.toDate()); } return visit; }
From source file:org.smartdeveloperhub.harvesters.it.testing.generator.ProjectActivityGenerator.java
License:Apache License
private double toPOSIXMillis(final LocalDateTime value) { return value.toDate().getTime(); }
From source file:org.xwiki.contrib.oidc.auth.internal.OIDCClientConfiguration.java
License:Open Source License
/** * @since 1.2/*from w ww . jav a 2 s . co m*/ */ public void resetUserInfoExpirationDate() { LocalDateTime expiration = LocalDateTime.now().plusMillis(getUserInfoRefreshRate()); setUserInfoExpirationDate(expiration.toDate()); }
From source file:org.xwiki.contrib.oidc.provider.internal.OIDCManager.java
License:Open Source License
/** * Generate an OIDC ID Token./*from www . j ava 2s . co m*/ * * @param clientID the client id * @param userReference the reference of the user * @param nonce the nonce * @param claims the custom fields to return * @return the id token * @throws ParseException when failing to create the id token * @throws MalformedURLException when failing to get issuer * @since 1.3 */ public JWT createdIdToken(ClientID clientID, DocumentReference userReference, Nonce nonce, ClaimsRequest claims) throws ParseException, MalformedURLException { Issuer issuer = getIssuer(); Subject subject = getSubject(userReference); List<Audience> audiences = clientID != null ? Arrays.asList(new Audience(clientID)) : Collections.<Audience>emptyList(); LocalDateTime now = LocalDateTime.now(); LocalDateTime now1year = now.plusYears(1); IDTokenClaimsSet idTokenClaimSet = new IDTokenClaimsSet(issuer, subject, audiences, now1year.toDate(), now.toDate()); idTokenClaimSet.setNonce(nonce); // Add custom claims if (claims != null) { for (Entry claim : claims.getIDTokenClaims()) { switch (claim.getClaimName()) { case OIDCIdToken.CLAIM_XWIKI_INSTANCE_ID: idTokenClaimSet.setClaim(OIDCIdToken.CLAIM_XWIKI_INSTANCE_ID, this.instance.getInstanceId()); break; default: break; } } } // Convert to JWT return new PlainJWT(idTokenClaimSet.toJWTClaimsSet()); }
From source file:py.com.palermo.servicioarthy.impl.gestioncomercial.PortalGeneralService.java
public void setRespuestaEncuesta(RespuestaEncuesta r) { if (r.getFechaCadena() != null) { LocalDateTime localDateTime = LocalDateTime.parse(r.getFechaCadena(), DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ssZ")); r.setFecha(localDateTime.toDate()); }// w ww . ja va 2 s . c o m guarda(r); }