Hi community,
I try to put due date in date field during transition. I use this script :
// On récupère la valeur dans le champ date Livré Réal
def champDateLivre = getFieldById( "customfield_10400" )
// On crée un objet date
def dateDuJour = new Date();
// On crée la date du jour
dateDuJour = dateDuJour.format( "d/MMM/yy" );
// On récupère la valeur du champ date livré
def valeurInitiale = getFieldById( "customfield_10400" ).value
// Si la date n'est pas alimentée
if ( valeurInitiale == "" )
{
// On l'alimente avec la valeur de date du jour
champDateLivre.setFormValue(dateDuJour)
}
My résult is : 3/Jul/19 but I've got an error that say wrong format. Use d/MMM/yy
But is it.
When I pick the date manualy in calendar, I've got 3/Juil./19
How can I synchronize it ? Exemple force french calendar... or other
You can get the datepicker format of the current date based on the current user's language using the following:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.datetime.DateTimeFormatterFactory
import com.atlassian.jira.datetime.DateTimeStyle
def formatterFactory = ComponentAccessor.getComponent(DateTimeFormatterFactory.class)
def localDatePicker = formatterFactory.formatter().forLoggedInUser().withStyle(DateTimeStyle.DATE_PICKER)
localDatePicker.format(new Date())
Thanks for your answer, but it doesn't work. Does it mean that my user have an other language compare to my systeme ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You'll need to provide more details if you want help.
Are you getting errors/stack traces?
What date string is inputted in your date field?
This was just an example of how to get the date in the user's format. Try it in the scriptrunner console.
To apply to your code, you will need to do something like
champDateLivre.setFormValue(localDatePicker.format(new Date()))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I missed the good application.
It's wonderfull, it's work !
Thank you very much Peter-Dave
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.