# Converting string to java.util.date

**URL:** <https://forum.inductiveautomation.com/t/converting-string-to-java-util-date/62194>\
**Category:** Ignition\
**Created:** [July 22, 2022, 5:53am UTC](https://forum.inductiveautomation.com/t/converting-string-to-java-util-date/62194 "2022-07-22T05:53:39Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sri\_Haran](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@Sri\_Haran](https://forum.inductiveautomation.com/u/Sri_Haran)\
**Post date:** [July 22, 2022, 5:53am UTC](https://forum.inductiveautomation.com/t/converting-string-to-java-util-date/62194/1 "2022-07-22T05:53:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 22, 2022, 9:55am UTC](https://forum.inductiveautomation.com/t/converting-string-to-java-util-date/62194/2 "2022-07-22T09:55:00Z")

</div>

If it’s coming in as a string, try using [system.date.parse()](https://docs.inductiveautomation.com/display/DOC81/system.date.parse).

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [July 22, 2022, 12:19pm UTC](https://forum.inductiveautomation.com/t/converting-string-to-java-util-date/62194/3 "2022-07-22T12:19:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Sri\_Haran](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@Sri\_Haran](https://forum.inductiveautomation.com/u/Sri_Haran)\
**Post date:** [July 23, 2022, 6:47am UTC](https://forum.inductiveautomation.com/t/converting-string-to-java-util-date/62194/4 "2022-07-23T06:47:44Z")

</div>

it was timestamp without timezone

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 23, 2022, 9:53am UTC](https://forum.inductiveautomation.com/t/converting-string-to-java-util-date/62194/5 "2022-07-23T09:53:58Z")

</div>

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)`?

---

<div class="post-metadata">

**Author:** ![Sri\_Haran](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@Sri\_Haran](https://forum.inductiveautomation.com/u/Sri_Haran)\
**Post date:** [July 28, 2022, 9:59am UTC](https://forum.inductiveautomation.com/t/converting-string-to-java-util-date/62194/6 "2022-07-28T09:59:03Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/3/434497418b03b2ba06ed1cbd9a96ec9e6dfc0ff5.png)  
Thanks & Regards,  
Sri

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 28, 2022, 10:01am UTC](https://forum.inductiveautomation.com/t/converting-string-to-java-util-date/62194/7 "2022-07-28T10:01:22Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![Sri\_Haran](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@Sri\_Haran](https://forum.inductiveautomation.com/u/Sri_Haran)\
**Post date:** [July 28, 2022, 10:03am UTC](https://forum.inductiveautomation.com/t/converting-string-to-java-util-date/62194/8 "2022-07-28T10:03:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 28, 2022, 10:04am UTC](https://forum.inductiveautomation.com/t/converting-string-to-java-util-date/62194/9 "2022-07-28T10:04:52Z")

</div>

No worries, Sri.

> [@Sri\_Haran](#):
>
> it was \<type ‘java.util.Date’\>

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

---

<div class="post-metadata">

**Author:** ![Sri\_Haran](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@Sri\_Haran](https://forum.inductiveautomation.com/u/Sri_Haran)\
**Post date:** [July 28, 2022, 10:10am UTC](https://forum.inductiveautomation.com/t/converting-string-to-java-util-date/62194/10 "2022-07-28T10:10:47Z")

</div>

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