2005 IR Help Posted August 23, 2006 Share Posted August 23, 2006 By: Brutus - gwhizzzzz Epoch Date Conversion 2004-03-08 02:15 Hi, I'm trying to convert an epoch date integer into a normal date. My epoch dates are store in a SQL2000 DB and I can only query them as a java.lang.integer. Other formats fail. I've had some success using datavision where I can use inline ruby to do the conversion. eg "t = Time.at({dbo.Records.Cur_Bill_EDate}) t.strftime("%d/%m/%y")" Is possible to do something similar in jasper? Say create a new var and use a java command to convert the epoch date to something usefull? Thanks, Brutus By: David Lim - aberrant80 RE: Epoch Date Conversion 2004-03-08 04:07 You can embed java code into the text field expression itself. I don't know what's Epoch, so just an example: <textFieldExpression class="java.lang.String"> MyClass.convertDate($F{DateField}) </textFieldExpression> By: Brutus - gwhizzzzz RE: Epoch Date Conversion 2004-03-08 08:28 Thks, Sorry the epoch time as in UNIX time from 1970. I've tried allsorts of Java syntax with no luck. Am I on the right track? New Var called $V{testvar} with the expression of: new Date($V{testvar}).toDate($F{Cur_Bill_EDate}) By: Tobias Gaekle - ike987 RE: Epoch Date Conversion 2004-03-08 08:48 the Date constructor takes a long value as an argument, so convert your Integer to long. new Date($F{your_integer_field}.longValue()) now you have a Date you could format with the pattern attribute or a formatter like SimpleDateFormat. By: Brutus - gwhizzzzz RE: Epoch Date Conversion 2004-03-09 00:33 Thanks that works very well Link to comment Share on other sites More sharing options...
maarts Posted January 23, 2007 Share Posted January 23, 2007 I don't have java experience and having the same issue. Can someone tell me what to fill in where in iReports. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now