I am trying to migrate cart data onto Hybris DB where the requirement is to insert the cart entries as the current date and time. When Testing the Impex on the HAC I get the same error what I get from the cronJobs logs.
I am currently using the following Impex
$coupon=appliedCouponCodes[collection-delimiter=|][merge=true]
$user=user[unique=true,translator=com.mycompanyname.core.dataimport.translator.MyCompanyNameOrgCartCustomerFromWebOrgId]
$store=store[unique=true,translator=com.mycompanyname.core.dataimport.translator.MyCompanyNameQuoteSiteToStoreTranslator]
#% impex.definitions.put("$currentDate", java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern("MMM d, yyyy, h:mm:ss a")))
INSERT_UPDATE Cart;code[unique=true];$user;site(uid);$store;date[dateformat="MMM d, yyyy hh:mm:ss a"][default="Mar 2, 2004, 1:24:33 p"];currency(isocode)[default=CAD]
;"2300001";"100005_w";"ca.mycompanybasesite.com";"ca.mycompanybasestore.com";$currentDate
Now when I hardcode the date-time value onto the data or keep it blank to get the default value it will run the impex which suggests that that there are no other dependencies on the translator being used. the below error only pops out when I use the variable $currentDate
INSERT_UPDATE Cart;code[unique=true];user[unique=true,translator=com.avantor.core.dataimport.translator.AvantorOrgCartCustomerFromWebOrgId];site(uid);store[unique=true,translator=com.avantor.core.dataimport.translator.AvantorQuoteSiteToStoreTranslator];"date[dateformat=""MMM dd, yyyy hh:mm:ss a""][default=""Mar 2, 2004, 1:24:33 p""]";currency(isocode)[default=CAD]
",,,,cannot parse date '$currentDate' with specified pattern '""MMM d' due to Unparseable date: ""$currentDate""";2300001;100005_w;ca.mycompanybasesite.com;ca.mycompanybasestore.com;$currentDate
I tried testing the impex on the HAC to which I found the above error, I also tried running the line in an online Java compiler
System.out.println(java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern("MMM d, yyyy, h:mm:ss a")))
which returns:
Oct 8, 2023, 10:23:41 AM
to which, I had no issues with getting the date-time in the correct format. I have tried other date-time formats as no luck with that as well.
I also tried formatting the date using this answer (SimpleDateFormat), this (Kindoff my current implementation) and this (I tried considering this) but to no avail. The issue still comes.
Any pointing to the right direction would help
I am on the 2211.9 version of SAP Commerce Cloud