bazaarvoice / jolt

JSON to JSON transformation library written in Java.
Apache License 2.0
1.56k stars 329 forks source link

Date Format conversion #1231

Closed G-Balamurugan closed 9 months ago

G-Balamurugan commented 9 months ago

Whether we can , change the date format

Input : { "date" : "2024-03-01" }

Output : { "date" : "01/03/2024" }

bobeal commented 9 months ago

Not something Jolt really shines in but you can achieve it with the following transformation:

[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "year": "=substring(@(1,date), 0, 4)",
      "month": "=substring(@(1,date), 5, 7)",
      "day": "=substring(@(1,date), 8, 10)",
      "date": "=concat(@(1,day),'/',@(1,month),'/',@(1,year))"
    }
  },
  {
    "operation": "remove",
    "spec": {
      "year": "",
      "month": "",
      "day": ""
    }
  }
]
G-Balamurugan commented 9 months ago

Thanks @bobeal , for your quick response