List of usage examples for org.joda.time Years yearsBetween
public static Years yearsBetween(ReadablePartial start, ReadablePartial end)
Years
representing the number of whole years between the two specified partial datetimes. From source file:org.kuali.rice.kim.impl.identity.personal.EntityBioDemographicsBo.java
License:Educational Community License
@Override public Integer getAge() { if (this.birthDateValue != null && !isSuppressPersonal()) { DateTime endDate;//w w w.j a va 2 s. c om if (this.deceasedDateValue != null) { endDate = new DateTime(this.deceasedDateValue); } else { endDate = new DateTime(); } return Years.yearsBetween(new DateTime(this.birthDateValue), endDate).getYears(); } return null; }
From source file:org.lightjason.agentspeak.action.buildin.datetime.CYearsBetween.java
License:LGPL
@Override protected final Stream<?> apply(final Stream<List<Instant>> p_datetime) { return p_datetime.map(i -> Years.yearsBetween(i.get(0), i.get(1))).mapToLong(Years::getYears).boxed(); }
From source file:org.lightjason.agentspeak.action.builtin.datetime.CYearsBetween.java
License:LGPL
@Nonnull @Override/*from w w w . j ava 2 s . co m*/ protected final Stream<?> apply(@Nonnull final Stream<List<Instant>> p_datetime) { return p_datetime.map(i -> Years.yearsBetween(i.get(0), i.get(1))).mapToDouble(Years::getYears).boxed(); }
From source file:org.mifos.application.importexport.xls.XlsClientsImporter.java
License:Open Source License
private void validateAge(final Date dateOfBirth) throws CellException, ConfigurationException { final DateMidnight dob = new DateMidnight(dateOfBirth); final DateTime now = new DateTime(); final Years age = Years.yearsBetween(dob, now); final int minimumAge = ClientRules.getMinimumAge(); final int maximumAge = ClientRules.getMaximumAge(); if (age.getYears() < 0) { throw new CellException(getMessage(XlsMessageConstants.FUTURE_DATE)); } else if (ClientRules.isAgeCheckEnabled() && !ClientRules.isAgeCheckWarningInsteadOfErrorEnabled() && (age.getYears() < minimumAge || age.getYears() > maximumAge)) { throw new CellException( getMessage(XlsMessageConstants.INVALID_AGE, new Object[] { minimumAge, maximumAge })); }/* w w w. j ava 2s .c om*/ }
From source file:org.mifos.customers.personnel.business.PersonnelBO.java
License:Open Source License
public String getAge() { if (this.personnelDetails != null && this.personnelDetails.getDob() != null && !this.personnelDetails.getDob().equals("")) { LocalDate fromDate = new LocalDate(this.personnelDetails.getDob()); Years years = Years.yearsBetween(new LocalDate(), fromDate); return Integer.valueOf(years.getYears()).toString(); }/*from w w w . jav a 2 s .c o m*/ return ""; }
From source file:org.mifosplatform.portfolio.pgs.pgsclient.domain.PGSClient.java
License:Mozilla Public License
public void updateIncentiveAttributes(final Long ageLimitForChildren, final Long ageLimitForSeniorCitizen, final LocalDate compareOnDate) { boolean isFemale = false; boolean isChild = false; boolean isSeniorCitizen = false; if (this.gender != null) { // FIXME: this needs to be handled in better way if (this.gender.label().equalsIgnoreCase("FEMALE")) { isFemale = true;/*from w w w . ja v a 2 s. c o m*/ } } if (this.dateOfBirth != null) { final LocalDate dobLacalDate = LocalDate.fromDateFields(this.dateOfBirth); final int age = Years.yearsBetween(dobLacalDate, compareOnDate).getYears(); if (age >= ageLimitForSeniorCitizen.intValue()) { isSeniorCitizen = true; } if (age <= ageLimitForChildren.intValue()) { isChild = true; } } this.incentiveAttributes = ClientIncentiveAttributes.instance(isFemale, isChild, isSeniorCitizen); }
From source file:org.mrgeo.featurefilter.DateColumnFeatureFilter.java
License:Apache License
private boolean datePassesFilter(DateTime date, DateTime filter) { return ((dateFilterGranularity.equals(DateGranularity.AFTER) && date.isAfter(filter)) || (dateFilterGranularity.equals(DateGranularity.BEFORE) && date.isBefore(filter)) || (dateFilterGranularity.equals(DateGranularity.SAME_INSTANT) && filter.isEqual(date)) || (dateFilterGranularity.equals(DateGranularity.WITHIN_A_MINUTE) && (Minutes.minutesBetween(filter, date).getMinutes() == 0)) || (dateFilterGranularity.equals(DateGranularity.WITHIN_AN_HOUR) && (Hours.hoursBetween(filter, date).getHours() == 0)) || (dateFilterGranularity.equals(DateGranularity.WITHIN_A_DAY) && (Days.daysBetween(filter, date).getDays() == 0)) || (dateFilterGranularity.equals(DateGranularity.WITHIN_A_MONTH) && (Months.monthsBetween(filter, date).getMonths() == 0)) || (dateFilterGranularity.equals(DateGranularity.WITHIN_A_YEAR) && (Years.yearsBetween(filter, date).getYears() == 0)) || (dateFilterGranularity.equals(DateGranularity.SAME_MINUTE_OF_ANY_HOUR) && (date.getMinuteOfHour() == filter.getMinuteOfHour())) || (dateFilterGranularity.equals(DateGranularity.SAME_HOUR_OF_ANY_DAY) && (date.getHourOfDay() == filter.getHourOfDay())) || (dateFilterGranularity.equals(DateGranularity.SAME_DAY_OF_ANY_WEEK) && (date.getDayOfWeek() == filter.getDayOfWeek())) || (dateFilterGranularity.equals(DateGranularity.SAME_DAY_OF_ANY_MONTH) && (date.getDayOfMonth() == filter.getDayOfMonth())) ||// www . jav a 2s . co m //date.getDayOfYear isn't sufficient here, b/c leap years have a different number of days (dateFilterGranularity.equals(DateGranularity.SAME_DAY_OF_ANY_YEAR) && ((date.getDayOfMonth() == filter.getDayOfMonth()) && (date.getMonthOfYear() == filter.getMonthOfYear()))) || (dateFilterGranularity.equals(DateGranularity.SAME_MONTH_OF_ANY_YEAR) && (date.getMonthOfYear() == filter.getMonthOfYear()))); }
From source file:org.ojbc.bundles.adapters.staticmock.samplegen.FirearmRegistrationSampleGenerator.java
License:RPL License
private void addRegistrationElement(Element rootElement, PersonElementWrapper person, DateTime baseDate, int firearmIndex) { Element registrationElement = appendElement(rootElement, OjbcNamespaceContext.NS_FIREARM_EXT, "ItemRegistration"); XmlUtils.addAttribute(registrationElement, OjbcNamespaceContext.NS_STRUCTURES, "id", "R" + firearmIndex); Element e = appendElement(registrationElement, OjbcNamespaceContext.NS_NC, "RegistrationIdentification"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "IdentificationID"); e.setTextContent(generateRandomID("", 12)); e = appendElement(registrationElement, OjbcNamespaceContext.NS_NC, "LocationCountyName"); e.setTextContent(getRandomCounty(person.state)); e = appendElement(registrationElement, OjbcNamespaceContext.NS_NC, "RegistrationEffectiveDate"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "Date"); DateTime registrationDate = generateNormalRandomDateBefore(baseDate, 5 * 365); e.setTextContent(XML_DATE_FORMAT.print(registrationDate)); e = appendElement(registrationElement, OjbcNamespaceContext.NS_FIREARM_EXT, "AgeAtRegistration"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "MeasureText"); e.setTextContent("" + Years.yearsBetween(person.birthdate, registrationDate).getYears()); e = appendElement(registrationElement, OjbcNamespaceContext.NS_FIREARM_EXT, "PermitNumber"); e.setTextContent(generateRandomID("", 12)); e = appendElement(registrationElement, OjbcNamespaceContext.NS_FIREARM_EXT, "PermitDate"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "Date"); e.setTextContent(XML_DATE_FORMAT.print(registrationDate)); Element statusElement = appendElement(registrationElement, OjbcNamespaceContext.NS_FIREARM_EXT, "RegistrationStatus"); e = appendElement(statusElement, OjbcNamespaceContext.NS_NC, "StatusDate"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "Date"); e.setTextContent(XML_DATE_FORMAT.print(registrationDate)); e = appendElement(statusElement, OjbcNamespaceContext.NS_FIREARM_EXT, "FirearmRegistrationStatusText"); e.setTextContent(coinFlip(.7) ? "Active" : "Inactive"); e = appendElement(registrationElement, OjbcNamespaceContext.NS_FIREARM_EXT, "RegistrationNotesText"); e.setTextContent("Notes"); }
From source file:org.ojbc.bundles.adapters.staticmock.samplegen.IncidentSampleGenerator.java
License:RPL License
private void addSubjectPersonElement(Incident incident, Element digestElement, DateTime baseDate) { PersonElementWrapper person = incident.subject; Element entityPersonElement = appendElement(digestElement, OjbcNamespaceContext.NS_LEXSDIGEST, "EntityPerson"); Element personElement = appendElement(entityPersonElement, OjbcNamespaceContext.NS_LEXSDIGEST, "Person"); XmlUtils.addAttribute(personElement, OjbcNamespaceContext.NS_STRUCTURES, "id", person.personId); Element personAgeMeasureElement = appendElement(personElement, OjbcNamespaceContext.NS_NC, "PersonAgeMeasure"); Element e = appendElement(personAgeMeasureElement, OjbcNamespaceContext.NS_NC, "MeasurePointValue"); int ageInYears = Years.yearsBetween(person.birthdate, baseDate).getYears(); e.setTextContent(String.valueOf(ageInYears)); e = appendElement(personAgeMeasureElement, OjbcNamespaceContext.NS_NC, "TimeUnitCode"); e.setTextContent("ANN"); Element personAlternateNameElement = appendElement(personElement, OjbcNamespaceContext.NS_NC, "PersonAlternateName"); e = appendElement(personAlternateNameElement, OjbcNamespaceContext.NS_NC, "PersonGivenName"); e.setTextContent(person.firstName + " A"); e = appendElement(personAlternateNameElement, OjbcNamespaceContext.NS_NC, "PersonSurName"); e.setTextContent(person.lastName);//from ww w . ja v a 2s . com e = appendElement(personElement, OjbcNamespaceContext.NS_NC, "PersonBirthDate"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "Date"); e.setTextContent(DATE_FORMATTER_YYYY_MM_DD.print(person.birthdate)); e = appendElement(personElement, OjbcNamespaceContext.NS_NC, "PersonEyeColorText"); e.setTextContent(generateRandomCodeFromList("Blue", "Brown", "Hazel")); e = appendElement(personElement, OjbcNamespaceContext.NS_NC, "PersonHairColorText"); e.setTextContent(generateRandomCodeFromList("Black", "Brown", "Blonde")); Element personHeightMeasureElement = appendElement(personElement, OjbcNamespaceContext.NS_NC, "PersonHeightMeasure"); e = appendElement(personHeightMeasureElement, OjbcNamespaceContext.NS_NC, "MeasurePointValue"); e.setTextContent(String.valueOf(Math.round(Integer.parseInt(person.centimeters) * .39))); e = appendElement(personHeightMeasureElement, OjbcNamespaceContext.NS_NC, "LengthUnitCode"); e.setTextContent("INH"); Element personNameElement = appendElement(personElement, OjbcNamespaceContext.NS_NC, "PersonName"); e = appendElement(personNameElement, OjbcNamespaceContext.NS_NC, "PersonGivenName"); e.setTextContent(person.firstName); e = appendElement(personNameElement, OjbcNamespaceContext.NS_NC, "PersonSurName"); e.setTextContent(person.lastName); // Note: this is the field used to identify multiple incidents belonging to the same person // It is the mock's equivalent of a "master name index" in an RMS Element otherId = appendElement(personElement, OjbcNamespaceContext.NS_NC, "PersonOtherIdentification"); e = appendElement(otherId, OjbcNamespaceContext.NS_NC, "IdentificationID"); e.setTextContent(person.id); e = appendElement(otherId, OjbcNamespaceContext.NS_NC, "IdentificationSourceText"); e.setTextContent(getClass().getName()); e = appendElement(personElement, OjbcNamespaceContext.NS_NC, "PersonRaceText"); e.setTextContent(generateRandomCodeFromList("W", "B", "U")); e = appendElement(personElement, OjbcNamespaceContext.NS_NC, "PersonSexCode"); e.setTextContent(person.sex.substring(0, 1).toUpperCase()); Element ssn = appendElement(personElement, OjbcNamespaceContext.NS_NC, "PersonSSNIdentification"); e = appendElement(ssn, OjbcNamespaceContext.NS_NC, "IdentificationID"); e.setTextContent(person.nationalID); e = appendElement(ssn, OjbcNamespaceContext.NS_NC, "IdentificationSourceText"); e.setTextContent("SSA"); Element pwm = appendElement(personElement, OjbcNamespaceContext.NS_NC, "PersonWeightMeasure"); e = appendElement(pwm, OjbcNamespaceContext.NS_NC, "MeasurePointValue"); e.setTextContent(person.pounds); e = appendElement(pwm, OjbcNamespaceContext.NS_NC, "WeightUnitCode"); e.setTextContent("LBR"); Element personAugmentationElement = appendElement(personElement, OjbcNamespaceContext.NS_JXDM_40, "PersonAugmentation"); e = appendElement(personAugmentationElement, OjbcNamespaceContext.NS_NC, "DriverLicense"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "DriverLicenseIdentification"); Element dl = e; e = appendElement(dl, OjbcNamespaceContext.NS_NC, "IdentificationID"); e.setTextContent(generateRandomID(person.state, 7)); e = appendElement(dl, OjbcNamespaceContext.NS_JXDM_40, "IdentificationJurisdictionNCICLISCode"); e.setTextContent(person.state); e = appendElement(personAugmentationElement, OjbcNamespaceContext.NS_JXDM_40, "PersonFBIIdentification"); Element fbi = e; e = appendElement(fbi, OjbcNamespaceContext.NS_NC, "IdentificationID"); e.setTextContent(generateRandomID("", 6) + generateRandomLetter() + generateRandomLetter() + generateRandomID("", 1)); e = appendElement(personAugmentationElement, OjbcNamespaceContext.NS_JXDM_40, "PersonStateFingerprintIdentification"); Element sid = e; e = appendElement(sid, OjbcNamespaceContext.NS_NC, "IdentificationID"); e.setTextContent(generateRandomID("A", 7)); e = appendElement(sid, OjbcNamespaceContext.NS_JXDM_40, "IdentificationJurisdictionNCICLISCode"); e.setTextContent(person.state); e = appendElement(entityPersonElement, OjbcNamespaceContext.NS_JXDM_40, "IncidentSubject"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "RoleOfPersonReference"); XmlUtils.addAttribute(e, OjbcNamespaceContext.NS_STRUCTURES, "ref", person.personId); }
From source file:org.ojbc.bundles.adapters.staticmock.samplegen.IncidentSampleGenerator.java
License:RPL License
private void addPersonElement(DateTime baseDate, PersonElementWrapper person, Element entityPersonElement, String roleName) {//from w w w.j ava 2s. co m Element personElement = appendElement(entityPersonElement, OjbcNamespaceContext.NS_LEXSDIGEST, "Person"); XmlUtils.addAttribute(personElement, OjbcNamespaceContext.NS_STRUCTURES, "id", person.personId); Element e = appendElement(personElement, OjbcNamespaceContext.NS_NC, "PersonAgeMeasure"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "MeasurePointValue"); int ageInYears = Years.yearsBetween(person.birthdate, baseDate).getYears(); e.setTextContent(String.valueOf(ageInYears)); e = appendElement(personElement, OjbcNamespaceContext.NS_NC, "PersonBirthDate"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "Date"); e.setTextContent(DATE_FORMATTER_YYYY_MM_DD.print(person.birthdate)); Element personNameElement = appendElement(personElement, OjbcNamespaceContext.NS_NC, "PersonName"); e = appendElement(personNameElement, OjbcNamespaceContext.NS_NC, "PersonGivenName"); e.setTextContent(person.firstName); e = appendElement(personNameElement, OjbcNamespaceContext.NS_NC, "PersonSurName"); e.setTextContent(person.lastName); e = appendElement(personElement, OjbcNamespaceContext.NS_NC, "PersonRaceText"); e.setTextContent(generateRandomCodeFromList("W", "B", "U")); e = appendElement(personElement, OjbcNamespaceContext.NS_NC, "PersonSexCode"); e.setTextContent(person.sex.substring(0, 1).toUpperCase()); e = appendElement(entityPersonElement, OjbcNamespaceContext.NS_JXDM_40, roleName); e = appendElement(e, OjbcNamespaceContext.NS_NC, "RoleOfPersonReference"); XmlUtils.addAttribute(e, OjbcNamespaceContext.NS_STRUCTURES, "ref", person.personId); }