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");
}
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();
}
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();
}
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();
}
}
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;
}
Aggregations