I am getting a java.sql.Timestamp from a database request. This value indicates an instant in time so timezone is not relevant (for that matter java.sql.Timestamp does not have a timezone, as it represents a global instant). I wish to use dataweave to convert this to an ISO8601 DateTime string, however dataweave is "adding" my local timezone (+10:00) to the value.
See Example:
%dw 2.0
output application/json
import java!java::sql::Timestamp
---
{
epoch: 0 as DateTime,
epochFromDatabase: Timestamp::new(0) as DateTime
}
where the result/preview is:
{
"epoch": "1970-01-01T00:00:00Z",
"epochFromDatabase": "1970-01-01T10:00:00Z"
}
You can see that the second value (epochFromDatabase) has +10 hours added to it despite being in UTC(Z).
Can this be corrected in dataweave only? I know I am able to correct this in java but I must only use dataweave/mule features.
-EDIT-- This is not a java issue as per example:
Timestamp epochTimestamp = new Timestamp(0);
System.out.println(epochTimestamp.toString());
System.out.println(epochTimestamp.toInstant().toString());
System.out.println(epochTimestamp.getTime());
Writes:
1970-01-01 10:00:00.0
1970-01-01T00:00:00Z
0
Such that toString does imply a local timesone (and not in iso8601), but when converted to an instant (whos toString defaults to ISO8601) it is correct.