autoformat()

Prev Next

This function is deprecated.

Returns the date created from an EDIFACT DTM segment with the format code a and the encoded date value b. See examples.

If a format code is used that is not allowed or a coded date value that does not match the format code, the error behaviour depends on parameter f (see examples).

Parameters

Parameter

Description

a

Format code. Allowed codes: 2-10, 101-110, 201-205, 301-306, 401-402, 404-406, 501-503, 600-604, 608-610, 613-616, 701-710, 713, 715-720, 801-814. Note: For the codes, see e.g. https://www.edifactory.de/edifact/directory/D96A/data-element/2379 or similar sites.

b

Encoded date value.

c

(optional) 1 if the 'from' part of a duration should be used, 2 if the 'until' part of a duration should be used. Default: 2. Note: 1 second is always automatically added to the 'until' part.

d

(optional) The time zone the date should be changed to before formatting. Default: The date's time zone.

Important note: The abbreviated forms should be avoided because some of them have been used for different time zones, making it impossible to ensure the usage of the correct one. Java only supports these forms for backwards compatibility reasons. After an update of the Java Virtual Machine or the operating system, it is possible that a profile returns a different result. Allowed abbreviations: GMT, UTC, SYSTEM (local time zone of server).

Examples:

America/New_York

Europe/Berlin

e

(optional) Locale. Default: System Locale. Note: Use the three dots to select a value.

f

(optional) This parameter controls the error behaviour (format code that is not allowed or coded date value that does not match the format code). If the parameter remains empty or the value error is used, a termination with exception follows. If the value empty is used, the return value is an empty string("") with set Empty Flag. If the value now is used, the return value is the current date. Default: <empty>. Note: Use the three dots to select a value.

g

(optional) If true, the return value (independent of the other settings) is always an empty string ("") with set Empty Flag. Default:false .

Examples

Parameter a

b

c

d

e

f

g

Result

305

12240802

2020-12-24 08:02:00.0

305

12240802

1

2020-12-24 08:02:00.0

305

12240802

Europe/Berlin

2020-12-24 08:02:00.0

305

12240802

America/New_York

2020-12-24 14:02:00.0

713

2009111200-2009131115

1

2020-09-11 12:00:00.0

713

2009111200-2009131115

2020-09-13 11:15:01.0

713

2009111200-2009131115

2

2020-09-13 11:15:01.0

714

2009111200-2009131115

Termination with an error (invalid code).

714

2009111200-2009131115

now

2023-01-30 (current date)

616

202101

de_DE

2021-01-04 (first calendar week 2021)

616

202101

en_US

2020-12-28 (first calendar week 2021)