Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X
Hi all,
i'm trying to import a file with a custom service based on a thing with "fileRepository" thing template.
The first filed is a date and, when I tested my service returns:
Wrapped org.joda.time.IllegalInstantException: Cannot parse "2010-03-28 02:01:34": Illegal instant due to time zone offset transition (Europe/Berlin) Cause: Cannot parse "2010-03-28 02:01:34": Illegal instant due to time zone offset transition (Europe/Berlin)
Here an example of my data:
2010-03-28 01:04:35
In my script I specified the date format as:
dateFormat: "yyyy-MM-dd HH:mm:ss" /* STRING */
I found a page in the support ptc portal that says (https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS192560&lang=en&source=snippet):
But when i put "z" in my date format:
dateFormat: "yyyy-MM-dd HH:mm:ssZ" /* STRING */
I get a generic error:
Wrapped java.lang.StringIndexOutOfBoundsException: String index out of range: 20 Cause: String index out of range: 20
Could you please help?
Thanks in adivce
Fulvio
cc: Marco Pagliotta - Marco Gioia
You can also import as String, and then parse it through server side JavaScript.
Hello Fulvio,
I am working on something related. I added timezone by adding UTC to received date String.
// 2016-05-25 09:28:20 is the date received but it requires to be UTC related so that "UTC+2 ThingWorx running instance" well manage the data
var dateToParse = "2016-05-25 09:28:20";
var datePrepared = dateToParse+" UTC";
var dateFormat = "yyyy-MM-dd HH:mm:ss zzz";
var result = parseDate(datePrepared,dateFormat);
Also documentation I found useful to use the following documentation for the dateFormat: