Jump to content
JasperReports 7.0 is now available ×

convert milliseconds to Date

Recommended Posts

How can I convert a unix time to datetime?

I am using jaspersoft studio 6.9.0

Ive set my field as;

<field name="user_start_date" class="java.util.Date"/>

and in the "Pattern Expression" Field I have tried;

new java.util.Date("MM-dd-yyyy HH:mm:ss z").format($F{user_start_date}.longValue()) 

new Date($F{user_start_date})

new SimpleDateFormat("MM-dd-yyyy HH:mm:ss z").format($F{user_start_date})

new DateTime(1970, 1, 1)).AddMilliseconds(double.Parse($F{user_start_date}))

A date value of 18,000 comes out perfectly as Jan 1, 1970

however a date value of 1717819200000 which should come out as June 8, 2024 comes out incorrectly as Jun 30, 1718

Turns out if I leave the "Pattern Expression" field blank, I have the same result.


Anyone have advise or a suggestion on what I could try?

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

I wanted to mention, its almost like jaspersoft is taking 1717819200000 and changing it to a negative number -1717819200000 before converting it to a date or datetime.

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