Hello team
I tried to compare two date , first the date of system , second the date of a custom field so the problem
is the date system return only day :
the date of custom field timestamp return this :
I need a help to compare the two dates
I need help
WARN [runner.ScriptRunnerImpl]: DDP 10
WARN [runner.ScriptRunnerImpl]: date de systeme Wed Dec 26 12:25:03 GMT+01:00 2018
Regards
@Adrián Plaza [DEISER] of course ,
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import java.text.SimpleDateFormat
long createdDateTime = issue.created.getTime()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField IncidentStartField = customFieldManager.getCustomFieldObject("customfield_10801");
// String IncidentStart = issue.getCustomFieldValue(IncidentStartField)
long IncidentStart = (issue.getCustomFieldValue(IncidentStartField) as Date).getDate();
log.warn("DDP " + IncidentStart )
def systemDate = new Date()
log.warn ("date de systeme " + systemDate.getTime() )
def warrantyField = customFieldManager.getCustomFieldObjectByName("DDP")
def warranty = issue.getCustomFieldValue(warrantyField)
log.warn("ddp " + warranty)
if (IncidentStart < systemDate)
{
]
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Karim Belhadj,
I made some modifications in your code and now looks like works fine:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import java.text.SimpleDateFormat
//Issue issue = ComponentAccessor.issueManager.getIssueByCurrentKey("KANBAN-8")
long createdDateTime = issue.created.getTime()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField IncidentStartField = customFieldManager.getCustomFieldObject("customfield_10801");
// String IncidentStart = issue.getCustomFieldValue(IncidentStartField)
Date IncidentStart = (issue.getCustomFieldValue(IncidentStartField) as Date)
log.error("IncidentStart " + IncidentStart )
Date systemDate = new Date()
log.error ("date de systeme " + systemDate )
if (IncidentStart.getTime() < systemDate.getTime()){
return true
}else{
return false
}
Can you try?
I hope this help,
Adrián.
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.
Hi @Karim Belhadj,
Can you send me the log output?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
yes
this is the log
2018-12-26 15:23:30,835 ERROR [runner.ScriptRunnerImpl]: IncidentStart 2018-12-27 00:00:00.0
2018-12-26 15:23:30,836 ERROR [runner.ScriptRunnerImpl]: date de systeme Wed Dec 26 15:23:30 GMT+01:00 2018
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Karim Belhadj,
Can you try with this code and show me the log:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import java.text.SimpleDateFormat
//Issue issue = ComponentAccessor.issueManager.getIssueByCurrentKey("KANBAN-8")
long createdDateTime = issue.created.getTime()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField IncidentStartField = customFieldManager.getCustomFieldObject("customfield_10801");
// String IncidentStart = issue.getCustomFieldValue(IncidentStartField)
Date IncidentStart = (issue.getCustomFieldValue(IncidentStartField) as Date)
log.error("IncidentStart " + IncidentStart +" and the time is "+ IncidentStart.getTime())
Date systemDate = new Date()
log.error ("date de systeme " + systemDate +" and the time is "+ systemDate.getTime())
if (IncidentStart.getTime() < systemDate.getTime()){
log.error("The incident start before the system date")
return true
}else{
log.error("The incident start after the system date")
return false
}
Adrián.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
this is the new log
2018-12-26 15:48:00,740 ERROR [runner.ScriptRunnerImpl]: IncidentStart 2018-12-27 00:00:00.0 and the time is 1545865200000
2018-12-26 15:48:00,741 ERROR [runner.ScriptRunnerImpl]: date de systeme Wed Dec 26 15:48:00 GMT+01:00 2018 and the time is 1545835680740
2018-12-26 15:48:00,741 ERROR [runner.ScriptRunnerImpl]: The incident start after the system date
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Karim Belhadj,
Now it's working well, you can compare system date with custom field date, this is what do you need? I am right?
Adrián.
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.