Altova MapForce 2025 Professional Edition

Converts a value of type xs:dateTime to a string. The string representation of date and time is formatted according to the value of the format argument.

mf-func-format-dateTime

 

Languages

Built-in, C++, C#, Java, XSLT 2.0, XSLT 3.0.

 

Parameters

Argument

Description

value

The xs:dateTime value to be formatted.

 

format

A format string identifying the way in which value is to be formatted. See Formatting below.

 

language

Optional argument. When supplied, the name of the month and the day of the week are returned in a specific language. Valid values are as follows:

 

de

German

en (default)

English

es

Spanish

fr

French

ja

Japanese

 

 

Note:If the function’s output (result) is connected to an item of type other than string, the formatting may be lost as the value is cast to the target type. To disable this automatic cast, clear the Cast target values to target types check box in the Component Settings of the target component.

 

Formatting

The format argument consists of a string that contains variable markers enclosed in square brackets (e.g., [Y]/[M]/[D]). Characters outside the square brackets are literal characters. If square brackets are needed as literal characters in the result, then they should be doubled.

 

Each variable marker consists of the following parts:

 

a specifier identifying which part of the data type is to be displayed (i.e., date or time),

an optional formatting modifier,

an optional presentation modifier, and

an optional width modifier, which must be preceded by a comma if it is present.

 

[variable marker] = [specifier(format)?(presentation)?(width)?]

 

where

 

width := , min-width ("-" max-width)?

 

Specifiers

The available specifiers are described in the table below.

 

Specifier

Description

Default Presentation

Y

year (absolute value)

four digits (2010)

M

month of the year

1-12

D

day of month

1-31

d

day of year

1-366

F

day of week

name of the day (language dependent)

W

week of the year

1-53

w

week of month

1-5

H

hour (24 hours)

0-23

h

hour (12 hour)

1-12

P

A.M. or P.M.

alphabetic (language dependent)

m

minutes in hour

00-59

s

seconds in minute

00-59

f

fractional seconds

numeric, one decimal place

Z

timezone as a time offset from UTC

+08:00

z

timezone as a time offset using GMT

GMT+n

 

Formatting modifiers

The formatting modifier can be any of the following:

 

Formatting modifier

Description

Example

1

Decimal numeric format with no leading zeros

1, 2, 3

01

Decimal format, two digits

01, 02, 03

N

Name of component, upper case

MONDAY, TUESDAY

n

Name of component, lower case

monday, tuesday

Nn

Name of component, upper/lower case

Monday, Tuesday

 

Important

The N, n, and Nn modifiers are supported by the following specifiers: M, F, and P. The N, n, and Nn modifiers are also supported by the z specifier but only in Built-In and code generation (Professional and Enterprise editions).

 

If you need a width modifier, put a comma before it. The width modifier is a digit that expresses the minimum width. Optionally, you can add a dash and a digit that expresses the maximum width. For example:

 

[D,2] is the day of the month, with leading zeros (two digits).

[MNn,3-3] is the name of the month, written as three characters, e.g., Jan, Feb, Mar, and so on.

 

Examples

The table below illustrates some examples of formatting xs:dateTime values with the help of the format-dateTime function. The Value column specifies the value supplied to the value argument. The Format column specifies the value of the format argument. The Result column shows what is returned by the function.

 

Value

Format

Result

2003-11-03T00:00:00

[D]/[M]/[Y]

3/11/2003

2003-11-03T00:00:00

[Y]-[M,2]-[D,2]

2003-11-03

2003-11-03T00:00:00

[Y]-[M,2]-[D,2] [H,2]:[m]:[s]

2003-11-03 00:00:00

2010-06-02T08:02:12.054

[Y] [MNn] [D01] [FNn,3-3] [d] [H]:[m]:[s].[f]

2010 June 02 Wed 153 8:02:12.054

2010-06-02T08:02:12.054+02:00

[Y] [MNn] [D01] [FNn,3-3] [d] [H]:[m]:[s].[f] [z]

2010 June 02 Wed 153 8:02:12.054 GMT+02:00

2010-06-02T08:02:12.054+02:00

[Y] [MNn] [D1] [FNn] [H]:[m]:[s].[f] [Z]

2010 June 2 Wednesday 8:02:12.054 +02:00

2010-06-02T08:02:12.054

[Y] [MNn] [D] [FNn,3-3] [H01]:[m]:[s]

2010 June 2 Wed 08:02:12

 

© 2018-2024 Altova GmbH