I have the following oql query running on visualvm against a heap dump and would like the creationTime
field formatted as a date time field (its stored as Long
).
select { id: s.id.toString(), createdAt: new Date(s.creationTime) }
from org.apache.catalina.session.StandardSession s
The above query lists the following output (snipped)
{
id = 1010827848,
createdAt = sun.org.mozilla.javascript.internal.NativeDate@66106135
}
...
So clearly its been "converted" into a Date but does not display it a human readable format. Doing a toString()
on the date object just results in the field being displayed as Invalid Date
.
BE27C51E8BF185A2FB3AA9164EC0C647
). What could be happening to that?createdAt: new java.util.Date(s.creationTime)
id
. See Retrieve "id" field values via VisualVM OQL query for more details. As a workaround you can use s["wrapped-object"].getValueOfField("id")
instead of s.id.toString()
With above changes your query should be:
select { id: s["wrapped-object"].getValueOfField("id"),
createdAt: new java.util.Date(s.creationTime).toString() }
from org.apache.catalina.session.StandardSession s