Date and Time Generator

Applies to ReadyAPI 3.56, last modified on November 21, 2024

The Date and Time generator is one of the Data Generators in ReadyAPI. It generates various date and time values and uses them in requests and responses.

To activate the Date and Time generator, select the desired property and set the Property Type to Date and Time:

Date and Time Data Generator

Click the image to enlarge it.

Parameters

After you have selected the Date and Time generator, ReadyAPI offers you to specify some additional parameters for the generated data:

Date/time Format

Specifies a list of the available date and time formats. If you want to specify a custom format for the date and time to be generated, select Custom in the Formats drop-down list and enter the desired format in the Date/time format string edit box. The default value of the parameter is HH:MM AM/PM.

See below for the formats’ description.

Format String

Specifies the format of the date or time to be generated. You can modify the parameter’s value only if you select the Custom item in the Date/Time format drop-down list.

ReadyAPI uses the SimpleDateFormat class to parse the date. This class considers all letter characters (from a to z and from A to Z) as part of the format pattern. You can use any other symbols to be used in the pattern. To specify letters that are not part of the format pattern, quote them using single quotes. To specify the single quote (') symbol, double it.

Usually, specifying the same letter several times changes the format to a longer version. For example:

  • M – Inserts the month number (1, 12).

  • MM – Inserts the month number with the leading zero (01, 12).

  • MMM – Inserts the short name of the month (Jan, Dec).

  • MMMM – Inserts the long name of the month (January, December).

The format string is case-sensitive. Note that some symbols have different meanings in different cases. For example, D specifies the day of the year (from 1 to 366), while d specifies the day of the month (from 1 to 31). So, if you want to specify a date in the format 1990-12-31, you should use the YYYY-MM-dd string.

The following list shows the most used representations of the letters. For the full description, see the class documentation.

Symbol Description Examples
y or Y Represents a year. 15
2015
M Represents a month. 1
01
Jan
January
w The number of a week in a year. 33
W The number of a week in a month. 3
D The number of a day in a year. 221
d The number of a day in a month. 8
E The name of a day of the week. Tue
Tuesday
a Inserts the AM or PM marker. PM
H The hour of the day in the 24-hour period. Midnight is shown as 0. 0
k The hour of the day in the 24-hour period. Midnight is shown as 24. 24
K The hour of the day in the 12-hour period. Midnight and noon are shown as 0. 10
h The hour of the day in the 12-hour period. Midnight and noon are shown as 12. 11
m Minutes in an hour. 32
s Seconds in a minute. 12

Generation Mode

Contains a drop-down list of the available generation modes:

  • Random – Select this mode to generate random date and time values within the specified range.

  • Sequential – Default. Select this mode to generate a sequence of values that will start from the Minimum value parameter. The sequence’s increment value is specified by the Increment value parameter.

Minimum Value

Specifies the lower bound of the date and time values to be generated.

Maximum Value

Specifies the upper bound of the date and time values to be generated.

Note: The value of the Maximum value parameter must be greater than or equal to the value of the Minimum value parameter.

Increment Value

Specifies an increment value for the generated sequence. The default value of the parameter is 1 day, 1 hour, 1 minute, 1 second.

Note: If you want to generate a descending sequence, specify a negative value for this parameter.
These parameters are available only if you select the Sequential item in the Generation mode drop-down list.

Duplicate Each Value … Time(s)

Specifies how many times each generated value will be duplicated. The default value of the parameter is False.

After you specify the needed parameters, you can obtain the sample values that have been generated by the engine. The values are displayed in the Sample field.

Also, you can discard all the changes you made in the generator’s parameters and restore the parameters set by default. To do that, click Set Default Values below the Sample field.

See Also

Date and Time (%TIME) Macro
Data Generator

Highlight search results