Converts a date and time value expressed as a string into a value of type xs:dateTime.
Built-in, C++, C#, Java.
The string value to be converted.
Specifies the format mask to apply to value.
A format mask can consist of the following components:
year (absolute value)
four digits (2010)
month of the year
day of month
day of year
hour (24 hours)
hour (12 hour)
A.M. or P.M.
alphabetic (language dependent)
minutes in hour
seconds in minute
numeric, one decimal place
timezone as a time offset from UTC
timezone as a time offset using GMT
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):
decimal numeric format with no leading zeros: 1, 2, 3, ...
1, 2, 3
decimal format, two digits: 01, 02, 03, ...
01, 02, 03
name of component, upper case
name of component, lower case
name of component, title case
|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:
21-03-2002 16:21:12.492 GMT+02:00
[D]-[M]-[Y] [H]:[m]:[s].[f] [z]
315 2004 +01:00
[d] [Y] [Z]
1.December.10 03:2:39 p.m. +01:00
[D].[MNn].[Y,2-2] [h]:[m]:[s] [P] [Z]
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):
See also Example: Write Data to Protocol Buffers.