List of usage examples for org.joda.time DateTime toDateMidnight
@Deprecated
public DateMidnight toDateMidnight()
DateMidnight
using the same millis and chronology. From source file:org.jasig.portlet.blackboardvcportlet.service.SessionForm.java
License:Apache License
public void setEndTime(DateTime endTime) { endDate = endTime.toDateMidnight(); endHour = endTime.getHourOfDay();//from ww w. j a va 2 s . co m endMinute = endTime.getMinuteOfHour(); endHourMinute = new LocalTime(endTime); }
From source file:org.ojbc.intermediaries.sn.subscription.SubscriptionRequest.java
License:RPL License
public SubscriptionRequest(Message message, String allowedEmailAddressPatterns) throws Exception { //Get the message body as DOM document = message.getBody(Document.class); reasonCategoryCode = XmlUtils.xPathStringSearch(document, "//submsg-exch:SubscriptionMessage/submsg-ext:CriminalSubscriptionReasonCode|//submsg-exch:SubscriptionMessage/submsg-ext:CivilSubscriptionReasonCode"); topic = XmlUtils.xPathStringSearch(document, "//b-2:Subscribe/b-2:Filter/b-2:TopicExpression"); topic = StringUtils.replace(topic, "topics:", "{http://ojbc.org/wsn/topics}:"); Node subscriptionMsg = XmlUtils.xPathNodeSearch(document, "//submsg-exch:SubscriptionMessage"); startDateString = XmlUtils.xPathStringSearch(subscriptionMsg, "nc:DateRange/nc:StartDate/nc:Date"); endDateString = XmlUtils.xPathStringSearch(subscriptionMsg, "nc:DateRange/nc:EndDate/nc:Date"); //Check start date versus end date here if (StringUtils.isNotBlank(startDateString) && StringUtils.isNotBlank(endDateString)) { DateTime startDate = DATE_FORMATTER.parseDateTime(startDateString); DateTime endDate = DATE_FORMATTER.parseDateTime(endDateString); if (endDate.toDateMidnight().isBefore(startDate.toDateMidnight())) { throw new Exception("End Date Can Not Be Before Start Date in a Subscription."); }/*w w w .j a va2 s .c om*/ } NodeList emailNodes = XmlUtils.xPathNodeListSearch(subscriptionMsg, "nc:ContactEmailID"); boolean wasEntryAddedToSet; if (emailNodes != null && emailNodes.getLength() > 0) { for (int i = 0; i < emailNodes.getLength(); i++) { if (emailNodes.item(i).getNodeType() == Node.ELEMENT_NODE) { if (emailAddresses == null) { emailAddresses = new HashSet<String>(); } wasEntryAddedToSet = emailAddresses.add(emailNodes.item(i).getTextContent()); if (!wasEntryAddedToSet) { log.warn("Email Address is a duplicate and will not be added to subscription: " + emailNodes.item(i).getTextContent()); } } } } if (emailAddresses == null || emailAddresses.size() == 0) { throw new Exception("The request does not contain any email addresses."); } EmailAddressPatternValidator emailAddressPatternValidator = new EmailAddressPatternValidator( allowedEmailAddressPatterns); //Check email addresses here EmailAddressValidatorResponse emailAddressValidatorResponse = emailAddressPatternValidator .areEmailAddressesValid(new ArrayList<String>(emailAddresses)); if (!emailAddressValidatorResponse.isAreAllEmailAddressValid()) { log.error("The request contains invalid email addresses."); List<String> invalidEmailAddress = new ArrayList<String>(); invalidEmailAddress.addAll(emailAddressValidatorResponse.getInvalidEmailAddresses()); throw new InvalidEmailAddressesException("The request contains invalid email addresses.", invalidEmailAddress); } systemName = XmlUtils.xPathStringSearch(subscriptionMsg, "submsg-ext:SystemName"); subjectName = XmlUtils.xPathStringSearch(subscriptionMsg, "submsg-ext:Subject/nc:PersonName/nc:PersonFullName"); subscriptionQualifier = XmlUtils.xPathStringSearch(subscriptionMsg, "submsg-ext:SubscriptionQualifierIdentification/nc:IdentificationID"); subscriptionSystemId = XmlUtils.xPathStringSearch(subscriptionMsg, "submsg-ext:SubscriptionIdentification/nc:IdentificationID"); agencyCaseNumber = XmlUtils.xPathStringSearch(subscriptionMsg, "submsg-ext:SubscriptionRelatedCaseIdentification/nc:IdentificationID"); // subjectIdentifiers intentionally left out - should be populated by derived class }
From source file:org.projectforge.framework.xstream.converter.JodaDateMidnightConverter.java
License:Open Source License
Object parse(final String data) { try {//from ww w. j ava 2s . co m final DateTimeFormatter parseFormat = DateTimeFormat.forPattern(ISO_FORMAT); final DateTime date = parseFormat.withZone(DateTimeZone.UTC).parseDateTime(data); final DateMidnight dateMidnight = date.toDateMidnight(); return dateMidnight; } catch (final Exception ex) { log.error("Can't parse DateMidnight: " + data); return new DateMidnight(); } }
From source file:org.slc.sli.bulk.extract.date.EntityDateHelper.java
License:Apache License
private static boolean isBeforeOrEqualDate(String begin, DateTime upToDate) { DateTime beginDate = (begin == null) ? DateTime.now().toDateMidnight().toDateTime() : DateTime.parse(begin, DateHelper.getDateTimeFormat()); return !beginDate.isAfter(upToDate.toDateMidnight().toDateTime()); }
From source file:se.vgregion.webbisar.types.BirthTime.java
License:Open Source License
public String getSmartTime(Date n) { DateTime now = new DateTime(n); DateTime lastMidnight = new DateTime(now.toDateMidnight()); DateTime lastTwoMidnight = new DateTime(lastMidnight).minusDays(1); DateTime lastWeek = new DateTime(lastMidnight).minusDays(6); DateTime birthTime = asDateTime();/*from ww w . j a v a 2 s . c o m*/ if (birthTime.isBefore(now) && birthTime.isAfter(lastMidnight)) { return "Idag"; } else if (birthTime.isBefore(lastMidnight) && birthTime.isAfter(lastTwoMidnight)) { return "Igr"; } else if (birthTime.isAfter(lastWeek)) { return "i " + weekDayFormatter.print(birthTime) + "s"; } return dateFormatter.print(birthTime); }
From source file:uk.org.rbc1b.roms.db.volunteer.interview.InterviewSession.java
License:Open Source License
/** * @return true if the session is today. *//*from w w w.j ava 2 s . co m*/ public boolean isToday() { DateTime today = LocalDate.now().toDateTimeAtStartOfDay(); DateTime sessionDate = DataConverterUtil.toDateTime(date); return today.isEqual(sessionDate.toDateMidnight()); }