# Loss of Accuracy when Parsing Strings with Milliseconds to DateTimes

**URL:** <https://forum.inductiveautomation.com/t/loss-of-accuracy-when-parsing-strings-with-milliseconds-to-datetimes/113251>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [January 13, 2026, 2:22pm UTC](https://forum.inductiveautomation.com/t/loss-of-accuracy-when-parsing-strings-with-milliseconds-to-datetimes/113251 "2026-01-13T14:22:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![francisco.salinas](https://avatars.discourse-cdn.com/v4/letter/f/ce73a5/32.png) [@francisco.salinas](https://forum.inductiveautomation.com/u/francisco.salinas)\
**Post date:** [January 13, 2026, 2:22pm UTC](https://forum.inductiveautomation.com/t/loss-of-accuracy-when-parsing-strings-with-milliseconds-to-datetimes/113251/1 "2026-01-13T14:22:11Z")

</div>

Hi everyone,  
I have a strange situation where I convert a string i.e. "2025-09-02T13:05:07.832" to a java.util.date object and the resulting datetime is off + or - by a few minutes.

When I remove the milliseconds from the string before parsing, the resulting datetime is accurate.

I did some investigating into the matter. There is support for parsing milliseconds via SimpleDateFormat but it seems that Jython in Designer for Ignition Platform 8.1.48 does not handle it well.

Has anyone encountered this or something similar before?

---

<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:** [January 13, 2026, 2:25pm UTC](https://forum.inductiveautomation.com/t/loss-of-accuracy-when-parsing-strings-with-milliseconds-to-datetimes/113251/2 "2026-01-13T14:25:54Z")

</div>

How are you parsing it?

Are you using `system.date.parse()`?

---

<div class="post-metadata">

**Author:** ![francisco.salinas](https://avatars.discourse-cdn.com/v4/letter/f/ce73a5/32.png) [@francisco.salinas](https://forum.inductiveautomation.com/u/francisco.salinas)\
**Post date:** [January 13, 2026, 3:18pm UTC](https://forum.inductiveautomation.com/t/loss-of-accuracy-when-parsing-strings-with-milliseconds-to-datetimes/113251/3 "2026-01-13T15:18:56Z")

</div>

I'm using SimpleDateFormat in the following manner:

```python
from java.text import SimpleDateFormat

time_str = "2026-01-13T09:17:00.744"
sdf = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS")
java_date = sdf.parse(time_str)

```

I'm using SimpleDateFormat because I need to accurately convert it to any timezone later with an arbitrary GMT offset. If there is some way to do this with system.date, I'm open to it.

---

<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 13, 2026, 3:41pm UTC](https://forum.inductiveautomation.com/t/loss-of-accuracy-when-parsing-strings-with-milliseconds-to-datetimes/113251/4 "2026-01-13T15:41:31Z")

</div>

Consider using [DateTimeFormatter](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/format/DateTimeFormatter.html) instead of `SimpleDateFormat`, as the latter interprets in the JVM's timezone. (`java.util.Date` is **always** UTC under the hood-it doesn't have a timezoneless form.)

The former's parse result can be fed to [LocalDateTime.from(...)](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/LocalDateTime.html#from(java.time.temporal.TemporalAccessor)) to instantiate a true timezoneless datetime object, which can then be fed to [ZonedDateTime.of(..., ZoneId z)](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/ZonedDateTime.html#of(java.time.LocalDateTime,java.time.ZoneId)) to get a zoned datetime that is independent of the JVM timezone.

You convert the `ZonedDateTime` back to `Date` via `Instant` (to use in Ignition APIs).

---

<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:** [January 13, 2026, 6:04pm UTC](https://forum.inductiveautomation.com/t/loss-of-accuracy-when-parsing-strings-with-milliseconds-to-datetimes/113251/5 "2026-01-13T18:04:15Z")

</div>

Works fine for me:

```python
from java.text import SimpleDateFormat

time_str = "2026-01-13T09:17:00.744"
sdf = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS")
java_date = sdf.parse(time_str)

print time_str
print sdf.format(java_date)
print java_date.time

```

```python
>>> 
2026-01-13T09:17:00.744
2026-01-13T09:17:00.744
1768324620744

```

Note that, some argument handling boilerplate aside, this is literally what `system.date.parse` is doing internally:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/e/0edc7003cd17bba8f6b4967cdc5a319394fb2fb7.png)

---

<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:** [January 13, 2026, 6:21pm UTC](https://forum.inductiveautomation.com/t/loss-of-accuracy-when-parsing-strings-with-milliseconds-to-datetimes/113251/6 "2026-01-13T18:21:07Z")

</div>

> [@paul-griffith](#):
>
> this is literally what `system.date.format` is doing internally

You mean `system.date.parse()` correct?
