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

Epoch Date Conversion


2005 IR Help

Recommended Posts

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

  • 4 months later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

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