# Are java datetime data types totally messed up in 8.0?

**URL:** <https://forum.inductiveautomation.com/t/are-java-datetime-data-types-totally-messed-up-in-8-0/24887>\
**Category:** Ignition\
**Created:** [May 10, 2019, 3:34pm UTC](https://forum.inductiveautomation.com/t/are-java-datetime-data-types-totally-messed-up-in-8-0/24887 "2019-05-10T15:34:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![brendan.curran](https://avatars.discourse-cdn.com/v4/letter/b/cdc98d/32.png) [@brendan.curran](https://forum.inductiveautomation.com/u/brendan.curran)\
**Post date:** [May 10, 2019, 3:34pm UTC](https://forum.inductiveautomation.com/t/are-java-datetime-data-types-totally-messed-up-in-8-0/24887/1 "2019-05-10T15:34:52Z")

</div>

I had dozens of scripts using java datetime libraries and datatypes and nearly all of them will literally write the wrong time to tags or insert queries. If I print it to the console or convert it to a string, it writes the correct time. If I write it to a tag or database, it usually writes the correct time subtract 4-5 hours. Makes no sense and seems like a pretty massive bug in 8.0.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 10, 2019, 3:37pm UTC](https://forum.inductiveautomation.com/t/are-java-datetime-data-types-totally-messed-up-in-8-0/24887/2 "2019-05-10T15:37:24Z")

</div>

There are a _lot_ of potential variables in what you’re describing - can you get in contact with support so we can have someone take a closer look at what you’re doing and what might be going wrong?

In short: to answer the question in the title, no, they are not _to our knowledge_ - that doesn’t mean they couldn’t be, but this is the first report of this issue I’ve seen.

---

<div class="post-metadata">

**Author:** ![jdrichards](https://avatars.discourse-cdn.com/v4/letter/j/839c29/32.png) [@jdrichards](https://forum.inductiveautomation.com/u/jdrichards)\
**Post date:** [December 31, 2019, 10:41pm UTC](https://forum.inductiveautomation.com/t/are-java-datetime-data-types-totally-messed-up-in-8-0/24887/3 "2019-12-31T22:41:04Z")

</div>

I upgraded from 7.9.10 on a new server with a restore of my gateway backup. I ran the new server in production to see if all was well. I upgraded to all the versions systematically to get to version 8.0.6. Now, running my new server, I get script faults saying my datetime conversions are leaving the decimal in the seconds and fail out. There has to be some changes.

no to mention, I can’t get my barcode scanners to work either…still working that issue as well

Caused by: org.python.core.PyException: Traceback (most recent call last): File “”, line 10, in File “C:\Program Files\Inductive Automation\Ignition\user-lib\pylib\datetime.py”, line 1791, in strptime struct, micros = \_strptime(date\_string, format) File “C:\Program Files\Inductive Automation\Ignition\user-lib\pylib\_strptime.py”, line 327, in \_strptime raise ValueError(“unconverted data remains: %s” % ValueError: unconverted data remains: .228000

… 25 common frames omitted

here is the script that works fine in 7.9.10

for row in rs:  
dt = row[“Date”]

# Wed Nov 01 00:00:00 CDT 2017

```
date_format = "%a %b %d %H:%M:%S %Z %Y"
dta = datetime.datetime.strptime(str(dt), date_format)
dbdatetime = datetime.datetime.strptime(str(dta), '%Y-%m-%d')
dbdatetimestr = str(dbdatetime)
dbdatetimestr = dbdatetimestr[:10]
```

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [December 31, 2019, 10:47pm UTC](https://forum.inductiveautomation.com/t/are-java-datetime-data-types-totally-messed-up-in-8-0/24887/4 "2019-12-31T22:47:17Z")

</div>

> [@brendan.curran](#):
>
> correct time subtract 4-5 hours

Does this by chance happen to correspond to UTC time?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 1, 2020, 4:32pm UTC](https://forum.inductiveautomation.com/t/are-java-datetime-data-types-totally-messed-up-in-8-0/24887/5 "2020-01-01T16:32:23Z")

</div>

Uhm, those aren’t java datetime types, but Jython. Jython changed from v2.5 to v2.7. I’ve always found python date/time objects to be less than reliable in jython, even before v8.

---

<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:** [January 2, 2020, 1:01pm UTC](https://forum.inductiveautomation.com/t/are-java-datetime-data-types-totally-messed-up-in-8-0/24887/6 "2020-01-02T13:01:29Z")

</div>

Are you just extracting the date? Two options for you:

1. dbdatetime should use strftime instead of strptime

```auto
dbdatetime = datetime.datetime.strftime(dta, '%Y-%m-%d')

```

1. Ignition has all sorts of new date functions for us to use. 🙂

```python
for row in rs:
   dt = row[“Date”]
   dbdatetimestr = system.date.format(dt, 'yyyy-MM-dd')

```
