Groovy web console

subscribe to the feed Subscribe
to this
site
Sorting with dates (via #groovywebconsole)
tweet this snippet Tweet
this
script

Sorting with dates

Published 1 month ago by daniel
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
//def value= ["/apidom-3.0.jar-hotfix-Ganges_3_1-poms_ui-2017-02-22-18-09-57","/apidom-3.0.jar-hotfix-Ganges_3_1-poms_ui-2017-02-23-15-03-39","/apidom-3.0.jar-hotfix-Ganges_3_1-poms_ui-2017-02-23-16-24-27","/apidom-3.0.jar-hotfix-Ganges_3_1-poms_ui-2017-02-27-14-40-44","/apidom-3.0.jar-hotfix-Ganges_3_1-poms_ui-2017-02-27-16-36-57"]
def employee = ["dev02-03-2017","moto-rel","redmi-h","cool-hot","dev02-04-2017","dev02-05-2017"];
def branch=["dev","rel","hot"]

//List of Env
def devList = []
def relList = []
def hotList = []

//Adding values to corresponding list
for(emp in employee) {     
if(emp.contains("dev"))
devList.add(emp)
if(emp.contains("rel"))
relList.add(emp)
if(emp.contains("hot"))
hotList.add(emp)
}

//Printing list
println devList
println relList
println hotList

def latest = ""
def next= ""
//for(dev in devList){
latest = devList[0].substring(3,13)
def newdate = new Date().parse("MM-dd-yyyy", latest)

latest = devList[1].substring(3,13)
def nextdate= new Date().parse("MM-dd-yyyy", latest)

println newdate
println nextdate

if(newdate < nextdate ) {
println "true" }