Converting the Date to Julian Date Format in Dataweave 2.0 (Mule 4)

How to Change the Date

Datawave 2.0 Code:

Java
 




xxxxxxxxxx
1
11


1
%dw 2.0
2
output application/json
3
import * from dw::core::Strings
4
fun year(date) = (date as Date).year
5
fun dayOfyear(date) = (date as Date).dayOfYear
6
fun C_value(date)= floor ((year(date) - (1900))/100)
7
fun JulianDate(date) = C_value(date) ++ (year(date) as String) [2 to 3] ++ leftPad(dayOfyear(date),3,"0")
8
---
9
{
10
JulianDate: JulianDate(<Provide some Date>)
11
}