# HG changeset patch
# User Ranjith S R <ranjith@qualiantech.com>
# Date 1553854706 -19800
#      Fri Mar 29 15:48:26 2019 +0530
# Node ID b78d4654c9b87b984afce5bcfb63ce637c63e1d4
# Parent  497591c4f1a65232a685db164f8d3f8a7a04eb98
Related to issue 40474 : Updated CloseSessionHook to avoid Parse error

diff -r 497591c4f1a6 -r b78d4654c9b8 src/org/openbravo/retail/sessions/CloseSessionHook.java
--- a/src/org/openbravo/retail/sessions/CloseSessionHook.java	Tue Mar 26 13:54:12 2019 -0400
+++ b/src/org/openbravo/retail/sessions/CloseSessionHook.java	Fri Mar 29 15:48:26 2019 +0530
@@ -1,6 +1,6 @@
 /*
  ************************************************************************************
- * Copyright (C) 2013-2017 Openbravo S.L.U.
+ * Copyright (C) 2013-2019 Openbravo S.L.U.
  * Licensed under the Openbravo Commercial License version 1.0
  * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
  * or in the legal folder of this module distribution.
@@ -9,7 +9,6 @@
 
 package org.openbravo.retail.sessions;
 
-import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
@@ -22,8 +21,6 @@
 
 public class CloseSessionHook implements CashupHook {
 
-  private static final DateFormat isodatefmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
-
   @Override
   public CashupHookResult exec(OBPOSApplications terminal, OBPOSAppCashup cashup,
       JSONObject cashUpJsonObj) throws Exception {
@@ -31,7 +28,12 @@
     Date businessDate = null;
     if (cashUpJsonObj.has("businessDate")
         && !StringUtils.isEmpty(cashUpJsonObj.optString("businessDate"))) {
-      businessDate = isodatefmt.parse(cashUpJsonObj.optString("businessDate"));
+      try {
+        businessDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS")
+            .parse(cashUpJsonObj.optString("businessDate"));
+      } catch (Exception e) {
+
+      }
     }
 
     SessionModelMessage msg = SessionModel.CloseTerminalSession(terminal, "T", cashup, businessDate,
