Tibco Businesswork,将时间戳格式设置为长格式为 mm/dd/yyyy

发布于 2024-08-21 19:05:38 字数 111 浏览 5 评论 0原文

我正在尝试使用监视表的 tibco adb 适配器发布 XML 消息。 表中有一列将日期存储为以毫秒为单位的长值 - 有没有办法可以将这个长值转换为日期作为 XML 编组的一部分?

-蒂亚

I'm trying to publish a XML message using the tibco adb adapter which monitors a table.
There is a column in the table that stores a date as a long value in milliseconds- Is there a way we can convert this long value to a date as a part of the XML marshalling ?

-tia

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

稚然 2024-08-28 19:05:38

您可以使用以下 x 路径将毫秒转换为日期时间 xml 值:

tib:add-to-dateTime(tib:translate-timezone('1970-01-01T00:00:00Z',  tib:get-timezone-from-dateTime(current-dateTime())), 0, 0, 0, 0, 0, (<your input in ms> div 1000))

其作用是:

1) 查找您的时区:

tib:get-timezone-from-dateTime(current-dateTime())

2) 将基准日期 (1970-01-01) 移动到正确的时区:

tib:translate-timezone('1970-01-01T00:00:00Z' <result above>)

3) 添加输入纪元中的秒数:

tib:add-to-dateTime(<result above>, 0, 0, 0, 0, 0, (<your input in ms> div 1000))

请注意,此解决方案的缺点是失去毫秒精度。最终日期时间以秒为单位。

如果您需要在最终结果中保留毫秒数,那么最好将其委托给外部 Java 库(正如有人已经建议的那样)。您可以通过 Java 自定义函数导入 Java 方法,轻松地在 Designer 映射器中使用 Java 方法资源。

You can translate the milliseconds to a datetime xml value with the following x-path:

tib:add-to-dateTime(tib:translate-timezone('1970-01-01T00:00:00Z',  tib:get-timezone-from-dateTime(current-dateTime())), 0, 0, 0, 0, 0, (<your input in ms> div 1000))

What this does is:

1) Find your timezone:

tib:get-timezone-from-dateTime(current-dateTime())

2) Move the base date (1970-01-01) to the correct timezone:

tib:translate-timezone('1970-01-01T00:00:00Z' <result above>)

3) Add the number of seconds in your input epoch:

tib:add-to-dateTime(<result above>, 0, 0, 0, 0, 0, (<your input in ms> div 1000))

Notice the downside to this solution is losing the milliseconds precision. The final datetime is in seconds.

If you need to keep the milliseconds in the final result, you are better off delegating this to an external Java library (as someone already suggested.) You can easily make a Java method available in the Designer mapper by importing it through a Java Custom Function resource.

盗琴音 2024-08-28 19:05:38

我必须编写一个自定义 java 进程来完成此任务 - 以防万一有人发现它有用

I had to write a custom java process to get this done - Just in case someone finds it useful

筱果果 2024-08-28 19:05:38

我已经遇到过很多次了。我们使用 Adb 中的选项将所有数据写入另一个表。然后您可以执行以下

选项 1
1、将另一个表的数据类型改为varchar
2.更新触发器为您进行电子转换
3.更新bw中的方案。
- 这将使您无法再使用 GUI 来更新 Adb

选项 2
我们用于 Adb 的另一种模式是使用 Adb 作为操作的触发器。因此,我们不使用 Adb 中的所有信息,而是使用密钥。我们对存储过程进行回调以检索它的其余部分。这是我们解决格式问题的地方。

因此,如果您熟悉在 bw 中进行数据库调用,那么第二个选项是迄今为止最简单且不易出错的选项。我们已经使用 Tibco 大约 3 年了,发现活动数据库适配器存在一些限制。在幕后,它只是一个带有 XML 序列化的表池程序,并将消息放置在队列/主题上

选项 3
我使用的另一个选项是在 BW 进程中创建一个相当复杂的映射器。搜索空格并将其替换为“t”。
希望这有帮助

I have ran into this quite a bit. We use the option in Adb to write all of the data to the other table. What you can do then do the following

Option 1
1. Change the data type of the other table to be varchar
2. Update the trigger to do e conversion for you
3. Update the scheme in bw.
- this will make it so you cannot use the GUI anymore for updates to Adb

Option 2
An alternate patter that we use for Adb is to use Adb as a trigger for an action. So instead of using all the information from Adb we use the key. We do a callback to a stored procedure to retrieve the rest of it. This is where we fix the formatting issue.

So if you are faimiliar with doing a db call in bw the second option is by far the easiest and less error prone. We have been using Tibco for about 3 years and have found some limitation to the active database adapter. Behind the scenes it is just a table pooler with an XML serialized and places the messages on a queue/topic

Option 3
The other option I have used is to create a pretty complicated mapper in your BW process. Search for a space and replace it with a "t".
Hope this helps

以往的大感动 2024-08-28 19:05:38

这对我有用,并采用最后没有“Z”的结果日期时间并添加毫秒,我就恢复了精度。现在只是计算出夏令时...

concat(
子串(
tib:add-to-dateTime(tib:translate-timezone('1970-01-01T00:00:00Z', tib:get-timezone-from-dateTime(current-dateTime())), 0, 0, 0, 0, 0, ($Element/root/s_date_in_ms div 1000))
,1,19)
,
“.”,
子字符串($Element/root/s_date_in_ms,12,3)
)

2014-11-10T23:02:28.858

This works for me, and taking the resulting date time without the 'Z' in the end and adding the milliseconds I have my precision back. Now just to work out the daylight saving time ...

concat(
substring(
tib:add-to-dateTime(tib:translate-timezone('1970-01-01T00:00:00Z', tib:get-timezone-from-dateTime(current-dateTime())), 0, 0, 0, 0, 0, ($Element/root/s_date_in_ms div 1000))
,1,19)
,
".",
substring($Element/root/s_date_in_ms,12,3)
)

2014-11-10T23:02:28.858

许一世地老天荒 2024-08-28 19:05:38
tib:add-to-dateTime('1970-01-01T00:00:00', 0, 0, 0, 0,0, (<<timeinmillisecond>> div 1000))
tib:add-to-dateTime('1970-01-01T00:00:00', 0, 0, 0, 0,0, (<<timeinmillisecond>> div 1000))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文