Fixes ISSUE-44574: Format date using provided timezone in OBBindings#formatDate
authorCristian Berner <cristian.berner@openbravo.com>
Mon, 27 Jul 2020 10:32:08 +0200
changeset 37503 8e534be16660
parent 37502 387029a95a3e
child 37504 ed3721aa757c
Fixes ISSUE 44574: Format date using provided timezone in OBBindings#formatDate

Previously as a side-effect date was being converted to UTC wrongly in
OBBindings formatDate function.
This fixes it by formatting using the local timezone as was previously
done prior to the regression commit. Fixes display of date in some
parameter windows that were relying on it (e.g. Costing Rules).

Fixes regression introduced in commit 4ec715bf
modules/org.openbravo.client.application/src/org/openbravo/client/application/OBBindings.java
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/OBBindings.java	Fri Jul 24 13:25:16 2020 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/OBBindings.java	Mon Jul 27 10:32:08 2020 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2019 Openbravo SLU
+ * All portions are Copyright (C) 2010-2020 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -33,6 +33,7 @@
 import org.openbravo.base.util.OBClassLoader;
 import org.openbravo.base.weld.WeldUtils;
 import org.openbravo.client.application.window.ApplicationDictionaryCachedStructures;
+import org.openbravo.client.kernel.reference.DateTimeUIDefinition;
 import org.openbravo.client.kernel.reference.UIDefinitionController;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
@@ -210,7 +211,8 @@
   }
 
   public String formatDateTime(Date d) {
-    return UIDefinitionController.DATETIME_UI_DEFINITION.convertToClassicString(d);
+    return ((DateTimeUIDefinition) UIDefinitionController.DATETIME_UI_DEFINITION)
+        .convertToClassicStringInLocalTime(d);
   }
 
   public String formatDateTime(Object d) {