Skip to main content
5-Regular Member
February 17, 2016
Solved

How to map Thingworx DATETIME to java Date?

  • February 17, 2016
  • 1 reply
  • 2802 views

Hi,

I have created Java extension to create a thing template and services.

One of the service extract Date from Thingworx mashup i.e. DATETIME picker and pass it to sql query eg. "select * from db_table where date between from_date and to_date".

So i created the service and defined parameter as

@ThingworxServiceParameter( name="From_Date", description="From Date", baseType="DATETIME" )  Date from_date

But when i run the service from Thingworx composer i get error as "Cannot cast org.joda.time.DateTime to java.lang.Date"

Can anyone help me here to pass date from mashup to java extension? Also how to convert that date to sql query mentioned above?

I found similar case at PTC support but there is no resolution. Date Issue when passing from one service to another service

Thanks,

Nagnath

Best answer by ngarad

Used org.joda.time.DateTime and issue got resolved.

@ThingworxServiceParameter( name="From_Date", description="From Date", baseType="DATETIME" )  DateTime from_date

1 reply

ngarad5-Regular MemberAuthorAnswer
5-Regular Member
March 17, 2016

Used org.joda.time.DateTime and issue got resolved.

@ThingworxServiceParameter( name="From_Date", description="From Date", baseType="DATETIME" )  DateTime from_date