+1 vote
1 view
in Salesforce by (11.3k points)

I am trying to convert a datetime column in a CSV to a salesforce datetime format to do an upsert. I tried expression like below in mule-3.8.4 dataweave1.0 but I am getting an error.

I tried the following:

Test_Date: "1/14/19 6:31 PM" as :localdatetime { format: "M/dd/yy h:mm a" } as :localdatetime { format: "YYYY-MM-DD'T'hh:mm:ssZ" })

Expected Output : 2019-01-14T06:31:00Z

Actual Output : Mon Jan 14 18:31:00 EST 2019

After Upsert in Salesforce, it looks like this: 2019-01-14T00:00:00.000+0000. It is not saving the time.

What is the problem?

1 Answer

+1 vote
by (28.6k points)

To format a date, the format pattern reading left to right, needs to match your expected output. So for your example:

2019-01-14T06:31:00Z

yyyy-MM-dd'T'HH:mm:ssZ

y is for year M is for Month(lowercase m is for minute

d is for day

H is for hour in 24 hr format. (Lowercase would be 12 be format)

S is for milliseconds

And Z is time zone There’s more you can configure for time zone and milliseconds if needed.

Here are the salesforce date format info:

https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/datafiles_date_format.htm

More date format info:

https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

...