You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I'm trying to fill in a date field via automation (smartvalue). The issue is created from another system via webhook, and I can't change the date format. How can I have jira parse an arbitrary date format, eg how can I provide the format string to parse the string into a date?
You will have to play with the string and date smart value functions.
String smart values: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/
Date smart values: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/
Regards
I don't see how that would work. The string functions are just things like substring, there is nothing like java.time.LocalDate.parse()
The second link only lets your format a date object in various ways, not generate one from a string (at least not that I can see).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Seth Hettich -- Welcome to the Atlassian Community!
Yes, and...to what Fabian suggests:
Once you get your date into a string/text format, try using toDate to convert it.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I can't seem to get it into a string fomat that toDate will accept, eg:
"{{issue.description.match("Created Time: (\d\d/\d\d/\d\d\d\d) \d\d:\d\d:\d\d [+]\d\d\d\d").replaceAll("(\d\d)/(\d\d)(\d\d\d\d)", "$2-$1-$3")}}"
generates a string the whole date (with slashes)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am unclear what that source format is you are getting, and I recommend starting with just the date in Jira Date format, yyyy-mm-dd, and write the source and the parsed values to the log as you confirm it. Once that works, try adding the time information.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The input comes in the description from an external system, so I can't change it.
The format is:
MM/DD/YYYY HH:MM:SS +Z
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for that information. I recommend parsing out the text version of the date/time as you have done and storing that in a created variable. Then try the toDate conversion on that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The issue is that call to replaceAll produces a string of the format "MM/DD/YYYY"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In that case, please take your replaceAll result, and save that in a created variable,
Then use other text functions such as substring() to pull that apart and put it into the jiraDate format yyyy-mm-dd, and
Then try the conversion with toDate.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.