Skip to content

Commit

Permalink
Merge pull request #1973 from jtobard/fix_date_format
Browse files Browse the repository at this point in the history
Fix date format
  • Loading branch information
gschueler committed Aug 1, 2016
2 parents 2cc71a5 + e699e87 commit 655edbd
Showing 1 changed file with 34 additions and 8 deletions.
Expand Up @@ -1530,14 +1530,27 @@ class ExecutionService implements ApplicationContextAware, StepExecutor, NodeSte
def Execution execution = createExecution(props)
execution.dateStarted = new Date()

if(execution.argString =~ /\$\{DATE:(.*)\}/){
if(execution.argString =~ /\$\{DATE(.*)\}/){

def newstr = execution.argString
try{
newstr = execution.argString.replaceAll(/\$\{DATE:(.*)\}/,{ all,tstamp ->
new SimpleDateFormat(tstamp).format(execution.dateStarted)
try {
newstr = execution.argString.replaceAll(/\$\{DATE(.*?)\}/, { all, tstamp ->
if(tstamp.lastIndexOf(":") == -1){
return all
}
final operator = tstamp.substring(0, tstamp.lastIndexOf(":"))
final fdate = tstamp.substring(tstamp.lastIndexOf(":")+1)
if(operator == ''){
new SimpleDateFormat(fdate).format(execution.dateStarted)
}else{
final number = operator as int
final newDate = execution.dateStarted +number
new SimpleDateFormat(fdate).format(newDate)
}
})
}catch(IllegalArgumentException e){
} catch (IllegalArgumentException e) {
log.warn(e)
} catch (NumberFormatException e){
log.warn(e)
}

Expand Down Expand Up @@ -1718,15 +1731,28 @@ class ExecutionService implements ApplicationContextAware, StepExecutor, NodeSte
Execution execution = createExecution(props)
execution.dateStarted = new Date()

if (execution.argString =~ /\$\{DATE:(.*)\}/) {
if (execution.argString =~ /\$\{DATE(.*)\}/) {

def newstr = execution.argString
try {
newstr = execution.argString.replaceAll(/\$\{DATE:(.*)\}/, { all, tstamp ->
new SimpleDateFormat(tstamp).format(execution.dateStarted)
newstr = execution.argString.replaceAll(/\$\{DATE(.*?)\}/, { all, tstamp ->
if(tstamp.lastIndexOf(":") == -1){
return all
}
final operator = tstamp.substring(0, tstamp.lastIndexOf(":"))
final fdate = tstamp.substring(tstamp.lastIndexOf(":")+1)
if(operator == ''){
new SimpleDateFormat(fdate).format(execution.dateStarted)
}else{
final number = operator as int
final newDate = execution.dateStarted +number
new SimpleDateFormat(fdate).format(newDate)
}
})
} catch (IllegalArgumentException e) {
log.warn(e)
} catch (NumberFormatException e){
log.warn(e)
}


Expand Down

0 comments on commit 655edbd

Please sign in to comment.