English 中文(简体)
Tibco Businesswork, format timestamp in long to mm/dd/yyyy
原标题:
  • 时间:2010-02-18 02:49:41
  •  标签:
  • tibco

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

问题回答

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.

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

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

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

tib:add-to-dateTime( 1970-01-01T00:00:00 , 0, 0, 0, 0,0, (<<timeinmillisecond>> div 1000))




相关问题
JMS error: can not send into foreign destinations

I use Spring-configured jms template with tibco jms library. I get jms connection factory and topic with JNDI and these objects are not null. But when I try to send message or add listener I get this ...

与春天混杂草

现在,我有一部 j瓦法,开始使用ti子,采取若干步骤:

Tibco Unit Testing tools [closed]

Does anyone know what unit testing tools are available when developing Tibco processes? In the next few months I ll be working on a Tibco project and I m trying to find any existing unit testing ...

Messaging pattern question

Process A is calculating values for objects a1, a2, a3 etc. and is sending results to the middleware queue (RabbitMQ). Consumers read the queue and process these results further. Periodically process ...

Tibco Businesswork, format timestamp in long to mm/dd/yyyy

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

TIBCO - BusinessWorks - Get path of the process dynamically

I am developing a process that will read and send an image in an e-mail. This image is a folder within this process. The problem is: how do I get the path where the process is running? Something ...

热门标签