use of org.hisp.dhis.period.Cal in project dhis2-core by dhis2.
the class EthiopianCalendarTest method testGenerateWeeklyPeriods.
@Test
public void testGenerateWeeklyPeriods() {
Date startDate = new Cal(1975, 1, 1, true).time();
Date endDate = new Cal(2025, 1, 2, true).time();
List<Period> weeks = new WeeklyPeriodType().generatePeriods(calendar, startDate, endDate);
assertEquals(2610, weeks.size());
}
use of org.hisp.dhis.period.Cal in project dhis2-core by dhis2.
the class PersianCalendarTest method testGenerateQuarterlyPeriods.
@Test
public void testGenerateQuarterlyPeriods() {
Date startDate = new Cal(2017, 3, 21, true).time();
Date endDate = new Cal(2017, 6, 21, true).time();
List<Period> monthly = new QuarterlyPeriodType().generatePeriods(calendar, startDate, endDate);
assertEquals(1, monthly.size());
}
use of org.hisp.dhis.period.Cal in project dhis2-core by dhis2.
the class DefaultSecurityService method initRestore.
@Override
public String[] initRestore(UserCredentials credentials, RestoreOptions restoreOptions) {
String token = restoreOptions.getTokenPrefix() + CodeGenerator.generateCode(RESTORE_TOKEN_LENGTH);
String code = CodeGenerator.generateCode(RESTORE_CODE_LENGTH);
String hashedToken = passwordManager.encode(token);
String hashedCode = passwordManager.encode(code);
RestoreType restoreType = restoreOptions.getRestoreType();
Date expiry = new Cal().now().add(restoreType.getExpiryIntervalType(), restoreType.getExpiryIntervalCount()).time();
credentials.setRestoreToken(hashedToken);
credentials.setRestoreCode(hashedCode);
credentials.setRestoreExpiry(expiry);
userService.updateUserCredentials(credentials);
return new String[] { token, code };
}
Aggregations