2017-05-18 55 views
2

我想2012-12-26轉換爲日期時間格式,爲了這個,我用下面的代碼爲dataweave:如何使用dataweave Mule將字符串轉換爲dateTime?

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

但它不工作,我有以下異常:

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

任何想法的傢伙?

+3

'2012-12-2600:00:00.000 + 00:00'缺少日和小時之間的'T'在'YYYY-MM-定義DD'T'HH:mm:ss.SSSXXX' – bradimus

+0

@bradimus,我加了'T',現在我得到了這個: '不能強制a:string到a:datetime,原因是:Text'2012-12-13T00 :00:00.000 + 00:00'無法解析:無法從TemporalAccessor:DateTimeBuilder獲取ZonedDateTime [fields = {WeekBasedYear [WeekFields [SUNDAY,1]] = 2012,MonthOfYear = 12,DayOfYear = 13,OffsetSeconds = 0 } ,ISO,null,null,0 0:00],輸入org.threeten.bp.format.DateTimeBuilder.' – CooperShelly

+0

您可能需要'dd',而不是'DD'。 'DD'是一年中的一天。 「dd」是一個月中的某一天。看看https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html – bradimus

回答

0

嘗試用這種

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