i'm trying to convert year and week number to Date, specifically i need to get first day of week by week number. My idea was to convert my String to Date and then gat firstdayofweek but im struggling with converting to Date with error:
Cannot coerce String (201601) to LocalDateTime, caused by: Text '201601' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {WeekOfWeekBasedYear[WeekFields[SUNDAY,1]]=1, Year=2016},ISO of type java.time.format.Parsed
My DW script:
%dw 2.0
output application/json
var date = '201601'
---
'Date' : date as LocalDateTime {format: "yyyyww"}
and also tried
%dw 2.0
output application/json
var date = '201601'
import * from dw::core::Periods
import * from dw::core::Dates
---
atBeginningOfWeek((atBeginningOfWeek(date[0 to 3]++ "-01-01")) as Date + days(date [4 to -1] * 7))
But they are not working good, any ideas?