Jump to content
We've recently updated our Privacy Statement, available here ×

Error filling print - Casting String to Date with iReport Design


jorgew.moura

Recommended Posts

I'm studying the iReport Design report tool and, when I tried convert a String object to Date, I received the message:

Error filling print... java.util.Date cannot be cast to java.lang.String[/code]

I tried convert it using:

new SimpleDateFormat("yyyyMMdd").parse($F{date})[/code]

$F{date} is the String that I get from the query. I try convert it in the Pattern Expr. of Text Field Properties of the $F{date}.

This don't work with Expression Class java.land.String and don't work with java.util.Date.

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

In a similar situation I had to make scriptlet with this

public String toDateFormat (String dateInput, String desiredFormat, String existingFormat ){    SimpleDateFormat sdfOld = new SimpleDateFormat(existingFormat);    Date date = null;    try {        date = sdfOld.parse(dateInput);    } catch (ParseException e) {        e.printStackTrace();    }    SimpleDateFormat sdfNew = new SimpleDateFormat(desiredFormat);    return String.valueOf(sdfNew.format(date));}[/code]

to be able affectively manage it. Surely it's reloaded with default formats that I use, to make it simplier, but approach still the same.

Link to comment
Share on other sites

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...