Welcome Guest! Log in
Stambia versions 2.x, 3.x, S17, S18, S19 and S20 are reaching End of Support January, 15th, 2024. Please consider upgrading to the supported Semarchy xDI versions. See Global Policy Support and the Semarchy Documentation.

The Stambia User Community is moving to Semarchy! All the applicable resources have already been moved or are currently being moved to their new location. Read more…


It is a common need to use system timestamps, and there is a variety of ways to use them, regarding:

- which timestamp is needed : the date/time at which the current session started, or the current real date/time

- how it is going to be used : as an insert value, as a timestamp in a filename, as a test condition...

This article shows some examples on how to use date/times in Stambia.

Session begin date / time

The date/time when the session started is stored in the CORE_BEGIN_DATE variable. You can consult it in the "Session details" view:

01-var

 

This variable can be used in any process, or mapping, or property in this way: ${/CORE_BEGIN_DATE}$

See the target field "mdate" in this mapping:

02-map

 

Begin and End dates of actions

It is possible to refer to the variable CORE_BEGIN_DATE or CORE_END_DATE of every action.

Just refer to the action path in the process. For example ${/ActionName/CORE_BEGIN_DATE}$ or ${/SubProcessName/ActionName/CORE_BEGIN_DATE}$

Sample process

In this example, we have four actions.

- SomeAction, Sleep and Sleep (2): no matter what they do, it is just for having a few actions that we can refer to in "printDates"

- printDates: this scripting action shows a few examples of how to use dates.

Notice how we used a relative path to refer to other actions, in variable names.

03-proc

 

Here is a sample output of the Runtime running this process:

18/06/2014 10:53:19,299 - timestamp (c0a84bc50146ae2e291d654770c04166) is started
--------
Session started at:     2014/06/18 10:53:19.299
beginDate is:           2014/06/18 10:53:19.299
psDatetime is:          2014/06/18 10:53:19.309
SomeAction started at:  2014/06/18 10:53:19.312
Sleep started at:       2014/06/18 10:53:19.337 and stopped at: 2014/06/18 10:53:22.338
Sleep (2) started at:   2014/06/18 10:53:22.341 and stopped at: 2014/06/18 10:53:23.344
Current date-time is:   2014/06/18 10:53:23.370
--------
18/06/2014 10:53:23,406 - timestamp (c0a84bc50146ae2e291d654770c04166) is ended

 

Naming a file with the current date/time

Consider the following file. Its physical name is timestamped with a function which will be replaced at execution with the current date/time.

04-md

 

If we have a simple mapping like this one:

05-map

 

Then the generated file will ben named like "nameWithTimestamp_20140618-113523-305.txt".

Note: if you execute this same mapping several times in the same process:

06-wrap

 

... then two different files will be generated:

nameWithTimestamp_20140618-113502-195.txt

nameWithTimestamp_20140618-113523-305.txt

 

Articles

Suggest a new Article!