Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,457,100
Community Members
 
Community Events
176
Community Groups

Parse a datestring in a smartvalue

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?

1 answer

0 votes
Fabian Lim Community Leader Dec 06, 2021

Hi @Seth Hettich

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).

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

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)

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.

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

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.

The issue is that call to replaceAll produces a string of the format "MM/DD/YYYY"

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.

Suggest an answer

Log in or Sign up to answer