format-dateTime

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  Functions > Function Library Reference > core | conversion functions >

format-dateTime

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

format-dateTime

Argument

Description

value

The xs:dateTime value to be formatted.

format

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

language

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

 

en (default)

English

es

Spanish

de

German

ja

Japanese

 

Note:If the function’s output (result) is connected to a node of type other than string, the formatting may be lost as the value is cast to the target type. This automatic cast can be disabled by unchecking the Cast target values to target types check box in the Component Settings of the target component (see Changing the Component Settings).

 

The format argument consists of a string containing so-called variable markers enclosed in square brackets. Characters outside the square brackets are literal characters to be copied into the result. 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, ...

1, 2, 3

01

decimal format, two digits: 01, 02, 03, ...

01, 02, 03

N

name of component, upper case

MONDAY, TUESDAY 1)

n

name of component, lower case

monday, tuesday 1)

Nn

name of component, title case

Monday, Tuesday 1)

 

Note:N, n, and Nn modifiers only support the following components: M, d, D.

 

The width modifier, if present, is introduced by a comma. It takes the form:

 

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

 

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


© 2019 Altova GmbH