DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Stop Writing Database Migration Scripts: Declarative Schema Sync for Java
  • Searching Kafka Without an Index: Lessons From Building Message Search for Kafdrop
  • ScyllaDB in Enterprise Java: High-Performance NoSQL With Eclipse JNoSQL
  • Member Spotlight: Shai Almong

Trending

  • Grounding AI Agents in Governed Data
  • How to Format Articles for DZone
  • What Cloud Engineers Actually Need to Know About AI Infrastructure
  • Who Should Grade Your AI? Rules vs LLM Judges vs Humans

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Coding
  3. Java
  4. Converting the Date to Julian Date Format in Dataweave 2.0 (Mule 4)

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

The article explains how to change the date using the Dataweave 2.0 code to convert the Date Format ("yyyy-MM-dd") to Julian Date Format.

By 
Abhishek Bathwal
·
Jan. 23, 21 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
9.2K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

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
}



When the current date is provided:

Java
 




x


 
1
Input:
2
now()
3

          
4
Output:
5
{
6
  "JulianDate": "121018"
7
}



When some manual date is provided:

Java
 




x


 
1
Input:
2
{
3
"Date": "2021-01-18"
4
}
5

          
6
Output:
7
{
8
"JulianDate": "121018"
9
}



When provided with the datetime:

Java
 




x


 
1
Input:
2
{
3
"Date": "2021-01-18T19:14:31.566+05:30"
4
}
5

          
6
Output:
7
{
8
"JulianDate": "121018"
9
}



Java (programming language)

Published at DZone with permission of Abhishek Bathwal. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Stop Writing Database Migration Scripts: Declarative Schema Sync for Java
  • Searching Kafka Without an Index: Lessons From Building Message Search for Kafdrop
  • ScyllaDB in Enterprise Java: High-Performance NoSQL With Eclipse JNoSQL
  • Member Spotlight: Shai Almong

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook