def
func:parseDateTime
parseDateTime(val, pattern: "YYYY-MM-DD'T'hh:mm:SS.FFFFFFFFFz zzzz", tz: now().tz, checked: true)
Parse a Str into a DateTime. If the string cannot be parsed into a valid DateTime and checked is false then return null, otherwise throw ParseErr. See DateTime.toLocale
for pattern:
YY Two digit year 07 YYYY Four digit year 2007 M One/two digit month 6, 11 MM Two digit month 06, 11 MMM Three letter abbr month Jun, Nov MMMM Full month June, November D One/two digit day 5, 28 DD Two digit day 05, 28 DDD Day with suffix 1st, 2nd, 3rd, 24th WWW Three letter abbr weekday Tue WWWW Full weekday Tuesday V One/two digit week of year 1,52 VV Two digit week of year 01,52 VVV Week of year with suffix 1st,52nd h One digit 24 hour (0-23) 3, 22 hh Two digit 24 hour (0-23) 03, 22 k One digit 12 hour (1-12) 3, 11 kk Two digit 12 hour (1-12) 03, 11 m One digit minutes (0-59) 4, 45 mm Two digit minutes (0-59) 04, 45 s One digit seconds (0-59) 4, 45 ss Two digit seconds (0-59) 04, 45 SS Optional seconds (only if non-zero) f* Fractional secs trailing zeros F* Fractional secs no trailing zeros a Lower case a/p for am/pm a, p aa Lower case am/pm am, pm A Upper case A/P for am/pm A, P AA Upper case AM/PM AM, PM z Time zone offset Z, +03:00 (ISO 8601, XML Schema) zzz Time zone abbr EST, EDT zzzz Time zone name New_York 'xyz' Literal characters '' Single quote literal
Examples:
parseDateTime("2023-02-07 14:30", "YYYY-MM-DD hh:mm") parseDateTime("2023-02-07 14:30", "YYYY-MM-DD hh:mm", "Paris") parseDateTime("7/2/23 2:30pm", "D/M/YY k:mma") parseDateTime("2023-02-07T14:30:00", "YYYY-MM-DD'T'hh:mm:ss")