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

convert a string field to date


gmcabral

Recommended Posts

Hello *:

I've the field $F{Fecha_y_hora-appointment_date}, string type, and I need to convert to date and assign a date pattern.

The field is like "yyyy-MM-dd HH:mm:ss" and I like to show "dd/MM/yyyy HH:mm".

I have found and I try this:

new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse($F{Fecha_y_hora-appointment_date})

But the result is like "Tue Jan 18 14:00:00"

Please give me a hand.

Gustavo.-

Link to comment
Share on other sites

  • 6 months later...

 This has worked in TextVariables, if I create a varaible as a String, etc but if I try to create a DATE Variable and use the SImpleDate, Utils.Date or whatever to convert a String to Date,  it throws Cannot Cast String to Date errors.  If I change the Variable to String, then I could play around and make it work.  But it defeats the purpose if I'm trying to convert returned Strings to Dates and then Group the Dates into Week One, Week Two, etc.  Nobody seems to have a clue how to do this.    Or maybe it's just not possible in Jasper to Convert String to Date and group by Week.   Because Convert String to Date and just display it doesn't do anything for Grouping or putting dates into Weeks.  It's still a String.

Link to comment
Share on other sites

  • 2 weeks later...

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