I’m trying to show both the epoch and local standard time next to each other from the output of a system.tag.queryTagHistory result.
The function call works fine, I’m putting the result on a custom value in the root of a page. Then I added a script transform to duplicate the t_stamp as t_stamp_readable and tried to add it as a java.util.timestamp but when I try to add the column to a dataset, it throws an error that I cant add a timestamp to a dataset.
Am I doing something wrong or should I try to add it as a string or something else? Any suggestions? Thanks!
Show the error(s) you are getting here. Post either your code or an example of the code you are using to attempt to add a column to the dataset. Make sure to post it as pre-formatted text, see Wiki - how to post code on this forum .
Line 9 is the return and the error is with java.sql.timestamp. Changing the type to str and java.util.date threw errors too. date couldn’t be coerced to a string and cant put a java.sql.timestamp into a java.util.date respectively. Thanks!
If you must manipulate time zone display yourself, you will suffer with java.util.Date and its subclasses (which includes java.sql.Timestamp) because they are zone-less objects. They parse and stringify in the JVM's default time zone, and you cannot use datetime arithmetic to correct this (produces subtle bugs).
Instead, create a java.time.Instant, and then a ZonedDateTime in the desired zone to print. That can be stringified reliably. (Use a date/time formatter for precise control.)
Thanks for the input, do you recommend a different way to display the same date twice from the queryTagHistory function? I’m not married to the idea of adding it twice if there is a better way, thanks again!
Adding another column to the source data is reasonable, but it should be a string produced from a ZonedDateTime, not another date object. Objects that aren't native JSON don't transfer to the front-end well.
If displaying in a Perspective table, you might avoid adding the raw data column by using a column render view that takes the one column and display both forms. (This will really only be helpful for large virtualized tables.)