diff --git a/lib/core/viewModel/profile/intervention_medication_view_model.dart b/lib/core/viewModel/profile/intervention_medication_view_model.dart index 998c7958..68b8cc2b 100644 --- a/lib/core/viewModel/profile/intervention_medication_view_model.dart +++ b/lib/core/viewModel/profile/intervention_medication_view_model.dart @@ -49,12 +49,8 @@ class InterventionMedicationViewModel extends BaseViewModel { InterventionMedicationReqModel( projectID: projectId, patientID: patientId, - fromDate: AppDateUtils.convertToServerFormat( - fromDate.toString(), - 'MM/dd/yyyy'), - toDate: AppDateUtils.convertToServerFormat( - toDate.toString(), - 'MM/dd/yyyy'), + fromDate: AppDateUtils.convertDateToServerFormat(fromDate), + toDate: AppDateUtils.convertDateToServerFormat(toDate), ); hasError = false; setState(ViewState.BusyLocal); diff --git a/lib/util/date-utils.dart b/lib/util/date-utils.dart index 7c68d649..65e755f9 100644 --- a/lib/util/date-utils.dart +++ b/lib/util/date-utils.dart @@ -28,6 +28,10 @@ class AppDateUtils { return '/Date(${DateFormat(dateFormat).parse(date).millisecondsSinceEpoch})/'; } + static String convertDateToServerFormat(DateTime date) { + return '/Date(${date.millisecondsSinceEpoch})/'; + } + static convertDateFromServerFormat(String str, dateFormat) { var date = getDateTimeFromServerFormat(str);