# Error in simpleTagProvider with DateTime tag

**URL:** <https://forum.inductiveautomation.com/t/error-in-simpletagprovider-with-datetime-tag/21283>\
**Category:** Module Development\
**Created:** [December 7, 2018, 12:54pm UTC](https://forum.inductiveautomation.com/t/error-in-simpletagprovider-with-datetime-tag/21283 "2018-12-07T12:54:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [December 7, 2018, 12:54pm UTC](https://forum.inductiveautomation.com/t/error-in-simpletagprovider-with-datetime-tag/21283/1 "2018-12-07T12:54:45Z")

</div>

Hi @paul-griffith,  
I try to use a **simpleTagProvider** based on the ignition-sdk-examples

> <https://github.com/inductiveautomation/ignition-sdk-examples/blob/master/SimpleTagProviderExample/stp-gateway/src/main/java/com/inductiveautomation/ignition/examples/stp/SimpleProviderGatewayHook.java>

It works well, except with Datetime tag DataType.  
I have an exception when I write in the tag from **Ignition (7.9.9)**

```auto
@Override
public Quality write(TagPath target, Object value) {
	Date val = TypeUtilities.toDate(value);

=> java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Date
	
	ourProvider.updateValue(target.toStringFull(), val, DataQuality.GOOD_DATA);
	return CommonQualities.GOOD;
});
```

---

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [December 7, 2018, 3:40pm UTC](https://forum.inductiveautomation.com/t/error-in-simpletagprovider-with-datetime-tag/21283/2 "2018-12-07T15:40:52Z")

</div>

The exception makes it sound like you are trying to write a string value to the tag.

Have you tried converting the value that you want to write to java.util.Date?

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [December 7, 2018, 3:45pm UTC](https://forum.inductiveautomation.com/t/error-in-simpletagprovider-with-datetime-tag/21283/3 "2018-12-07T15:45:14Z")

</div>

> [@mazeyrat](#):
>
> TypeUtilities.toDate(value);

I input the value from Ignition Designer.  
The purpose of

```auto
TypeUtilities.toDate(value);
```

is to cast the value.  
For my point of view, in the designer when you input the "date" value, a string is transmitted.

---

<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:** [December 7, 2018, 3:53pm UTC](https://forum.inductiveautomation.com/t/error-in-simpletagprovider-with-datetime-tag/21283/4 "2018-12-07T15:53:54Z")

</div>

> [@mazeyrat](#):
>
> For my point of view, in the designer when you input the "date" value, a string is transmitted.

Your expectations are a bit unrealistic. String to date conversion is a quagmire that is left to the application programmer.

---

<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:** [December 7, 2018, 3:59pm UTC](https://forum.inductiveautomation.com/t/error-in-simpletagprovider-with-datetime-tag/21283/5 "2018-12-07T15:59:31Z")

</div>

Is your string in one of the following date formats?  
`"yyyy-MM-dd", "MM/dd/yyyy", "MM/dd/yyyy HH:mm:ss", "hh:mm:ss a", "hh:mm a", "MM/dd/yyyy hh:mm:ss a", "yyyy-MM-dd HH:mm:ss.SSS", "yyyy-MM-dd HH:mm:ss", "EEE MMM dd HH:mm:ss z yyyy"`

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [December 7, 2018, 4:02pm UTC](https://forum.inductiveautomation.com/t/error-in-simpletagprovider-with-datetime-tag/21283/6 "2018-12-07T16:02:18Z")

</div>

No,  
when I edit the tag in the designer, I have something like : Wed Dec 05 16:29:05 CET 2018.

I have tried too :

```auto
import system
system.tag.write("[MyReplay]ControlTags/startDate",system.date.now())
```

and I have another error

```auto
Caused by: com.inductiveautomation.ignition.common.sqltags.parser.TagPathFormatException: Illegal character ']' (Line 1 , Char 10)
```

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/1/17da6916f1274695f81356c0016a7791ee9ae047.jpg)
