cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Wrapped org.joda.time.IllegalInstantException

fbrambilla
Newbie

Wrapped org.joda.time.IllegalInstantException

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):

  • Use the GMT/UTC timezone for date times
  • Add a Z directly after the time format without a space(Z is the zone indicator for the zero UTC offset)
    • yyyy-MM-dd'T'HH:mm:ssZ

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

2 REPLIES 2

Re: Wrapped org.joda.time.IllegalInstantException

You can also import as String, and then parse it through server side JavaScript.

Re: Wrapped org.joda.time.IllegalInstantException

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:

DateTimeFormat (Joda time 2.2 API)

Announcements

Check out the upcoming Expert Session: Understanding ThingWorx Navigate Licensing in Community "Customer Events" section.