to Zoned Date Time
fun String.toZonedDateTime(format: String? = null, useSystemTimeZone: Boolean = true): ZonedDateTime?
Works off of String representations of (zoned)date(time) and parses through the following attempts in order when no format is present:
- First, if the date is identified as MsftDate, then it'll attempt to parse & return value.
- Second, try to parse as ZonedDateTime, if successful returns value & converts to systemTimeZone if param value is set.
- Third, try to parse as LocalDateTime, if successful returns value & converts to systemTimeZone if param value is set.
- Lastly, try to parse as LocalDate, if successful returns value & adds start of daytime, & converts to systemTimeZone if param value is set, else returns null.
When a format is present however, it'll try parsing using that format alone, & return null if it fails. ZonedDateTime? Null means couldn't parse, else parsed ZonedDateTime.Return
Parameters
this
String representation of either MsftDate, LocalDate, LocalDateTime, or ZonedDateTime.
format
String representing format that should solely be used when parsing the date.
use System Time Zone
If true, converts parsed date to system default timezone, else keeps original time zone.