From 9caae656e2e67fa9448cb33f93e20e2801234892 Mon Sep 17 00:00:00 2001 From: Anil Patel Date: Fri, 27 Jul 2007 08:23:19 +0000 Subject: [PATCH] improvements to how date is parsed. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk/specialpurpose@560137 13f79535-47bb-0310-9956-ffa450edef68 --- .../ofbiz/oagis/OagisInventoryServices.java | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/oagis/src/org/ofbiz/oagis/OagisInventoryServices.java b/oagis/src/org/ofbiz/oagis/OagisInventoryServices.java index be96818f9..58694660b 100644 --- a/oagis/src/org/ofbiz/oagis/OagisInventoryServices.java +++ b/oagis/src/org/ofbiz/oagis/OagisInventoryServices.java @@ -137,20 +137,27 @@ public class OagisInventoryServices { statusId = "INV_ON_HOLD"; } - String snapshotDateStr = UtilXml.childElementValue(inventoryElement, "os:DATETIMEISO"); - - // In BOD the timestamp come in the format "yyyy-MM-dd'T'HH:mm:ss.SSSS'Z'Z" - // Parse this into a valid Timestamp Object - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSS'Z'Z"); - Timestamp snapshotDate = null; - try { - snapshotDate = new Timestamp(sdf.parse(snapshotDateStr).getTime()); - } catch (ParseException e) { - String errMsg = "Error parsing Date: " + e.toString(); - errorMapList.add(UtilMisc.toMap("reasonCode", "ParseException", "description", errMsg)); - Debug.logError(e, errMsg, module); + String snapshotDateStr = UtilXml.childElementValue(inventoryElement, "os:DATETIMEISO"); + //Parse this into a valid Timestamp Object + Date dateTimeInvReceived = null; + Timestamp snapshotDate = null; + try{ + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSS'Z'Z"); + dateTimeInvReceived = sdf.parse(snapshotDateStr); + }catch(ParseException e){ + Debug.logInfo("Message does not have timezone information in date field", module); + try{ + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSS'Z'"); + dateTimeInvReceived = sdf.parse(snapshotDateStr); + }catch(ParseException e1){ + String errMsg = "Error parsing Date: " + e1.toString(); + errorMapList.add(UtilMisc.toMap("reasonCode", "ParseException", "description", errMsg)); + Debug.logError(e, errMsg, module); + } + } + if(dateTimeInvReceived !=null){ + snapshotDate = new Timestamp( dateTimeInvReceived.getTime() ); } - // get quantity on hand diff double quantityOnHandTotal = 0.0;