简体   繁体   中英

How to convert String to dateTime using dataweave Mule?

I want to convert 2012-12-26 to a date time format, for this I used the following code into a dataweave:

("2012-12-26"++ "T00:00:00.000+00:00") as :datetime {class:"java.util.Calendar", format : "YYYY-MM-DD'T'HH:mm:ss.SSSXXX"}

But it doesn't work, I got the following exception:

Cannot coerce a :string to a :datetime, caused by :Text '2012-12-13T00:00:00.000+00:00' could not be parsed: Unable to obtain ZonedDateTime from TemporalAccessor: DateTimeBuilder[fields= {WeekBasedYear[WeekFields[SUNDAY,1]]=2012, MonthOfYear=12, DayOfYear=13, OffsetSeconds=0} , ISO, null, null, 00:00], type org.threeten.bp.format.DateTimeBuilder

Any idea guys?

试试这个

datetime: ("2017-03-02T00:00:00.000Z" replace "Z" with "+0700") as :datetime{format: "yyyy-MM-dd'T'HH:mm:ss.SSSZ"}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM