Unstable integration test due different timezones
This commit is contained in:
committed by
Arnold Gálovics
parent
7e680729fc
commit
55949bf8b0
+6
@@ -88,8 +88,14 @@ public class ClientEntityImportHandler implements ImportHandler {
|
||||
String name = ImportHandlerUtils.readAsString(ClientEntityConstants.NAME_COL, row);
|
||||
String officeName = ImportHandlerUtils.readAsString(ClientEntityConstants.OFFICE_NAME_COL, row);
|
||||
Long officeId = ImportHandlerUtils.getIdByName(workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME), officeName);
|
||||
if (officeId == 0L) {
|
||||
officeId = null;
|
||||
}
|
||||
String staffName = ImportHandlerUtils.readAsString(ClientEntityConstants.STAFF_NAME_COL, row);
|
||||
Long staffId = ImportHandlerUtils.getIdByName(workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME), staffName);
|
||||
if (staffId == 0L) {
|
||||
staffId = null;
|
||||
}
|
||||
LocalDate incorportionDate = ImportHandlerUtils.readAsDate(ClientEntityConstants.INCOPORATION_DATE_COL, row);
|
||||
LocalDate incorporationTill = ImportHandlerUtils.readAsDate(ClientEntityConstants.INCOPORATION_VALID_TILL_COL, row);
|
||||
String mobileNo = null;
|
||||
|
||||
+6
@@ -88,8 +88,14 @@ public class ClientPersonImportHandler implements ImportHandler {
|
||||
String middleName = ImportHandlerUtils.readAsString(ClientPersonConstants.MIDDLE_NAME_COL, row);
|
||||
String officeName = ImportHandlerUtils.readAsString(ClientPersonConstants.OFFICE_NAME_COL, row);
|
||||
Long officeId = ImportHandlerUtils.getIdByName(workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME), officeName);
|
||||
if (officeId == 0L) {
|
||||
officeId = null;
|
||||
}
|
||||
String staffName = ImportHandlerUtils.readAsString(ClientPersonConstants.STAFF_NAME_COL, row);
|
||||
Long staffId = ImportHandlerUtils.getIdByName(workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME), staffName);
|
||||
if (staffId == 0L) {
|
||||
staffId = null;
|
||||
}
|
||||
String externalId = ImportHandlerUtils.readAsString(ClientPersonConstants.EXTERNAL_ID_COL, row);
|
||||
LocalDate submittedOn = ImportHandlerUtils.readAsDate(ClientPersonConstants.SUBMITTED_ON_COL, row);
|
||||
LocalDate activationDate = ImportHandlerUtils.readAsDate(ClientPersonConstants.ACTIVATION_DATE_COL, row);
|
||||
|
||||
+29
-3
@@ -19,6 +19,7 @@
|
||||
package org.apache.fineract.infrastructure.core.service;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -74,6 +75,10 @@ public final class DateUtils {
|
||||
return createDate(localDate.getYear(), localDate.getMonthValue(), localDate.getDayOfMonth());
|
||||
}
|
||||
|
||||
public static LocalDate convertToLocalDate(final Date dateToConvert, final ZoneId zoneId) {
|
||||
return dateToConvert.toInstant().atZone(zoneId).toLocalDate();
|
||||
}
|
||||
|
||||
public static Date createDate(int year, int month, int day) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(Calendar.YEAR, year);
|
||||
@@ -97,10 +102,27 @@ public final class DateUtils {
|
||||
return today;
|
||||
}
|
||||
|
||||
public static LocalDate parseLocalDate(final String stringDate, final String pattern) {
|
||||
|
||||
public static Date parseDate(final String stringDate, final String pattern, final ZoneId zoneId) {
|
||||
try {
|
||||
final DateTimeFormatter dateStringFormat = DateTimeFormatter.ofPattern(pattern).withZone(getDateTimeZoneOfTenant());
|
||||
return new SimpleDateFormat(pattern).parse(stringDate);
|
||||
} catch (final ParseException e) {
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
final ApiParameterError error = ApiParameterError.parameterError("validation.msg.invalid.date.pattern",
|
||||
"The parameter date (" + stringDate + ") is invalid w.r.t. pattern " + pattern, "date", stringDate, pattern);
|
||||
dataValidationErrors.add(error);
|
||||
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.",
|
||||
dataValidationErrors, e);
|
||||
}
|
||||
}
|
||||
|
||||
public static LocalDate parseLocalDate(final String stringDate, final String pattern, final ZoneId zoneId) {
|
||||
try {
|
||||
DateTimeFormatter dateStringFormat;
|
||||
if (zoneId != null) {
|
||||
dateStringFormat = DateTimeFormatter.ofPattern(pattern).withZone(zoneId);
|
||||
} else {
|
||||
dateStringFormat = DateTimeFormatter.ofPattern(pattern);
|
||||
}
|
||||
final ZonedDateTime dateTime = ZonedDateTime.parse(stringDate, dateStringFormat);
|
||||
return dateTime.toLocalDate();
|
||||
} catch (final IllegalArgumentException e) {
|
||||
@@ -113,6 +135,10 @@ public final class DateUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static LocalDate parseLocalDate(final String stringDate, final String pattern) {
|
||||
return parseLocalDate(stringDate, pattern, getDateTimeZoneOfTenant());
|
||||
}
|
||||
|
||||
public static String formatToSqlDate(final Date date) {
|
||||
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
||||
df.setTimeZone(getTimeZoneOfTenant());
|
||||
|
||||
+1
-1
@@ -199,11 +199,11 @@ public class StandingInstructionWritePlatformServiceImpl implements StandingInst
|
||||
Collection<StandingInstructionData> instructionDatas = this.standingInstructionReadPlatformService
|
||||
.retrieveAll(StandingInstructionStatus.ACTIVE.getValue());
|
||||
List<Throwable> errors = new ArrayList<>();
|
||||
LocalDate transactionDate = DateUtils.getLocalDateOfTenant();
|
||||
for (StandingInstructionData data : instructionDatas) {
|
||||
boolean isDueForTransfer = false;
|
||||
AccountTransferRecurrenceType recurrenceType = data.recurrenceType();
|
||||
StandingInstructionType instructionType = data.instructionType();
|
||||
LocalDate transactionDate = LocalDate.now(DateUtils.getDateTimeZoneOfTenant());
|
||||
if (recurrenceType.isPeriodicRecurrence()) {
|
||||
final ScheduledDateGenerator scheduledDateGenerator = new DefaultScheduledDateGenerator();
|
||||
PeriodFrequencyType frequencyType = data.recurrenceFrequency();
|
||||
|
||||
Reference in New Issue
Block a user