Converts a date and time value expressed as a string into a value of type xs:dateTime.
Built-in, C++, C#, Java.
Argument |
Description |
---|---|
value |
The string value to be converted. |
format |
Specifies the format mask to apply to value. |
A format mask can consist of the following components:
Component |
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 |
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 |
Some of the components above take modifiers (for example, they can be used to interpret a date either as a single digit or as two digits):
Modifier |
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 |
FEBRUARY, MARCH |
n |
name of component, lower case |
february, march |
Nn |
name of component, title case |
February, March |
Note: | N, n, and Nn modifiers support only the component M (month). |
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.
The table below lists some format examples:
Value |
Format |
Result |
---|---|---|
21-03-2002 16:21:12.492 GMT+02:00 |
[D]-[M]-[Y] [H]:[m]:[s].[f] [z] |
2002-03-21T16:21:12.492+02:00 |
315 2004 +01:00 |
[d] [Y] [Z] |
2004-11-10T00:00:00+01:00 |
1.December.10 03:2:39 p.m. +01:00 |
[D].[MNn].[Y,2-2] [h]:[m]:[s] [P] [Z] |
2010-12-01T15:02:39+01:00 |
20110620 |
[Y,4-4][M,2-2][D,2-2] |
2011-06-20T00:00:00 |
In the mapping below, the string value 2019-12-24 19:43:04 +02:00 is converted into its dateTime equivalent, by applying the format mask [Y]-[M]-[D] [H]:[m]:[s] [Z].
The result is as follows (excluding the XML and namespace declarations):
<FlightInformation> |