Search in sources :

Example 6 with LocalDateTime

use of org.joda.time.LocalDateTime in project qi4j-sdk by Qi4j.

the class AbstractQueryTest method script41_LocalDateTime.

@Test
public void script41_LocalDateTime() {
    QueryBuilder<Person> qb = this.module.newQueryBuilder(Person.class);
    Person person = templateFor(Person.class);
    Query<Person> query = unitOfWork.newQuery(qb.where(ne(person.localDateTimeValue(), new LocalDateTime("2010-03-04T13:23:00", UTC))));
    System.out.println("*** script41_LocalDateTime: " + query);
    verifyUnorderedResults(query, "Joe Doe");
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) Person(org.qi4j.test.indexing.model.Person) Test(org.junit.Test)

Example 7 with LocalDateTime

use of org.joda.time.LocalDateTime in project SeriesGuide by UweTrottmann.

the class TimeTools method parseEpisodeReleaseDate.

/**
     * Calculates the episode release date time as a millisecond instant. Adjusts for time zone
     * effects on release time, e.g. delays between time zones (e.g. in the United States) and DST.
     *
     * @param showTimeZone See {@link #getDateTimeZone(String)}.
     * @param showReleaseTime See {@link #getShowReleaseTime(int)}.
     * @return -1 if no conversion was possible. Otherwise, any other long value (may be negative!).
     */
public static long parseEpisodeReleaseDate(@Nullable Context context, @NonNull DateTimeZone showTimeZone, @Nullable String releaseDate, @NonNull LocalTime showReleaseTime, @Nullable String showCountry, @Nullable String showNetwork, @NonNull String deviceTimeZone) {
    if (releaseDate == null || releaseDate.length() == 0) {
        return Constants.EPISODE_UNKNOWN_RELEASE;
    }
    // get date
    LocalDate localDate;
    try {
        localDate = TVDB_DATE_FORMATTER.parseLocalDate(releaseDate);
    } catch (IllegalArgumentException e) {
        // date string could not be parsed
        if (context != null) {
            Utils.trackCustomEvent(context, AnalyticsTree.CATEGORY_THETVDB_ERROR, "Date parsing failure", releaseDate);
        }
        Timber.e(e, "TheTVDB date could not be parsed: %s", releaseDate);
        return Constants.EPISODE_UNKNOWN_RELEASE;
    }
    // set time
    LocalDateTime localDateTime = localDate.toLocalDateTime(showReleaseTime);
    localDateTime = handleHourPastMidnight(showCountry, showNetwork, localDateTime);
    localDateTime = handleDstGap(showTimeZone, localDateTime);
    // finally get a valid datetime in the show time zone
    DateTime dateTime = localDateTime.toDateTime(showTimeZone);
    // handle time zone effects on release time for US shows (only if device is set to US zone)
    if (deviceTimeZone.startsWith(TIMEZONE_ID_PREFIX_AMERICA)) {
        dateTime = applyUnitedStatesCorrections(showCountry, deviceTimeZone, dateTime);
    }
    return dateTime.getMillis();
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) LocalDateTime(org.joda.time.LocalDateTime)

Example 8 with LocalDateTime

use of org.joda.time.LocalDateTime in project NabAlive by jcheype.

the class Nabaztag method convertJodaTimezone.

public static DateTime convertJodaTimezone(LocalDateTime date, String srcTz, String destTz) {
    DateTime srcDateTime = date.toDateTime(DateTimeZone.forID(srcTz));
    DateTime dstDateTime = srcDateTime.withZone(DateTimeZone.forID(destTz));
    return dstDateTime.toLocalDateTime().toDateTime();
}
Also used : DateTime(org.joda.time.DateTime) LocalDateTime(org.joda.time.LocalDateTime)

Example 9 with LocalDateTime

use of org.joda.time.LocalDateTime in project head by mifos.

the class PersonnelServiceImpl method changePassword.

@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);
    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();
    }
}
Also used : PersonnelUsedPasswordEntity(org.mifos.customers.personnel.business.PersonnelUsedPasswordEntity) LocalDateTime(org.joda.time.LocalDateTime) UserContext(org.mifos.security.util.UserContext) ArrayList(java.util.ArrayList) MifosRuntimeException(org.mifos.core.MifosRuntimeException) BusinessRuleException(org.mifos.service.BusinessRuleException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 10 with LocalDateTime

use of org.joda.time.LocalDateTime in project head by mifos.

the class LoginServiceFacadeWebTier method updatePassword.

@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();
    }
    personnelService.changePasswordExpirationDate(user, newExpirationDate);
    return passwordIsAlreadyChanged;
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) UserContext(org.mifos.security.util.UserContext) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) Date(java.util.Date) LocalDate(org.joda.time.LocalDate)

Aggregations

LocalDateTime (org.joda.time.LocalDateTime)66 Test (org.junit.Test)35 DateTime (org.joda.time.DateTime)15 Interval (org.joda.time.Interval)12 LocalDate (org.joda.time.LocalDate)11 ArrayList (java.util.ArrayList)5 Date (java.util.Date)5 ApplianceLogger (de.avanux.smartapplianceenabler.log.ApplianceLogger)4 BigDecimal (java.math.BigDecimal)4 BigInteger (java.math.BigInteger)4 DateTimeZone (org.joda.time.DateTimeZone)4 Person (org.qi4j.test.indexing.model.Person)4 HashMap (java.util.HashMap)3 Chronology (org.joda.time.Chronology)3 LocalTime (org.joda.time.LocalTime)3 de.avanux.smartapplianceenabler.appliance (de.avanux.smartapplianceenabler.appliance)2 BuddhistChronology (org.joda.time.chrono.BuddhistChronology)2 GJChronology (org.joda.time.chrono.GJChronology)2 ISOChronology (org.joda.time.chrono.ISOChronology)2 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)2