Forum Discussion
You are omitting the time, is it expected that way?
Please refer thread to parse
https://stackoverflow.com/questions/3817862/groovy-string-to-date
- senthkum5 years agoContributor
Thanks Mate,
I was able to resolve the older problem. But now I have another problem. What could be the issue for the below error?
I am not able to convert string date to date format, even though I have paresd.
def Fromdate = new Date().parse("yyyy-MM-dd'T'HH:mm:ss.000+11:00", FromDate).format('yyyy-MM-dd')
def Todate = new Date().parse("yyyy-MM-dd'T'HH:mm:ss.000+11:00", ToDate).format('yyyy-MM-dd')def intValue = Todate.minus(Fromdate) Is this the correct formate to find the datediff?
def Nofodays = intValue.toInteger()Error: Failed to dispatch using script; java.lang.NumberFormatException: For input string: "2020-02-19"
Thanks
Senthil. M
- nmrao5 years agoChampion Level 3What are you expecting in result? Sample data please?
- senthkum5 years agoContributor
Hi Rao,
I want to find the date difference to send my response. Should I add any .jar files to work on date format ?
If so, Can you provide the link plz.
Though the FromDate and ToDate is parsed it's still showing as string, due to that I am not able to do a datediff.
I have spent 2 days on this to resolve. Could you help me here.
def Fromdate = new Date().parse("yyyy-MM-dd'T'HH:mm:ss.000+11:00", FromDate).format('yyyy-MM-dd')
def Todate = new Date().parse("yyyy-MM-dd'T'HH:mm:ss.000+11:00", ToDate).format('yyyy-MM-dd')def intValue = Todate - Fromdate
def Nofodays = intValue.toInteger()if ((Nofodays >=8 ) || (Nofodays <= 15))
{
return "Fortnight"
}
else if ((Nofodays >=16 ) || (Nofodays <= 31))
{
return "Month"
}Thanks
Senthil. M