Jump to content
Changes to the Jaspersoft community edition download ×

Can not cast Date to String


Recommended Posts

By: Ringoman - novellusrules

Can not cast Date to String

2003-04-22 16:05

I keep getting this error when trying to compile a report.

 

S:ComitGreenjavadevUntitled_report_1.java:183: Invalid cast from java.util.Date to java.lang.String.

 

value = (java.lang.String)(((java.util.Date)field_teetime.getValue()));

 

Does anyone know what it's all about.

 

I've tried two diffrent jdk's 1.3 and 1.4 but both do the same thing.

 

 

 

 

By: Gregory A. Swarthout - gswarthout

RE: Can not cast Date to String

2003-04-22 16:21

Yes, you've most likely indicated a parameter or field is a

Date as in:

 

<parameter name="TeeTime" class="java.util.Date"/>

 

And then you are trying to use it somewhere where a String is

expected, like in a textFieldExpression.

 

If that is, indeed, the case, you need to convert it to a String with its toString() method or, perhaps, something similar to this:

 

new SimpleDateFormat("MM/dd/yy").format($P{TeeTime})

 

 

 

 

 

By: Ringoman - novellusrules

RE: Can not cast Date to String

2003-04-22 16:45

Thanks that help.

 

It now compiles fine. There must be a problem with ireports. That's what I used to create the report.

 

Now I've go to figure out why I get no data.

 

Thanks again.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...