Converting string to java.util.date

Hello All,
I’m in need of to compare a time interval between two time_stamp
where one from database and for another i use system.time.now() function
then to calculate time difference i used function called system.date.minutesBetween()
when i passed the 2 arg inside this function the first arg from database is showing like
TypeError: minutesBetween(): 1st arg can’t be coerced to java.util.Date
Any suggestion would be appreciated
Thanks

If it’s coming in as a string, try using system.date.parse().

3 Likes

What is the column type in the database table where the date is stored?

it was timestamp without timezone

And it’s coming in as a string? Or are you coercing it to a string?

What datatype do you get when you use something like print type(myTimeStampValue)?

1 Like

Hi @JordanCClark,
Sorry for the delay in reply the datatype was not a string it’s an arrayList


Thanks & Regards,
Sri

Well, that’s because you grabbed it as a list. :wink:

What about type(sri[0]) to get the type of the first value of the list?

Hey sorry @JordanCClark,
it was <type ‘java.util.Date’>
Regards,
Sri

No worries, Sri.

Huh. Well, there shouldn't be an issue with minutesBetween() then.

That’s fine man i used some other methods actually my requirement was changed from checking DB time to current time
Thanks
Sri

1 Like