Altova MapForce 2024 Enterprise 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 "Remarks" 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:

 

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.

 

Remarks

The format argument consists of a string containing so-called variable markers enclosed in square brackets, for example [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 a component specifier identifying which component of the date or time is to be displayed, an optional formatting modifier, another optional presentation modifier and an optional width modifier, preceded by a comma if it is present.

 

format := (literal | argument)*

argument := [component(format)?(presentation)?(width)?]

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

 

The components are as follows:

 

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

 

The formatting modifier can be one of the following:

 

Character

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 case1

MONDAY, TUESDAY

n

Name of component, lower case1

monday, tuesday

Nn

Name of component, title case1

Monday, Tuesday

 

Footnotes:

 

1. The N, n, and Nn modifiers are supported by the following components only: M, d, D.

 

The width modifier, if necessary, is introduced by a comma, followed by a digit that expresses the minimum width. Optionally, you can add a dash followed by another 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 illustrates 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

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

2010 June 02 Wed 153 8:02:12.054

2010-06-02T08:02

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

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

2010-06-02T08:02

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

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

2010-06-02T08:02

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

2010 June 2 Wed 08:02:12

© 2017-2023 Altova GmbH