Package dev.frostlake.functions.scalar
Class SnowflakeDateFormat
java.lang.Object
dev.frostlake.functions.scalar.SnowflakeDateFormat
Formats a temporal value with a subset of Snowflake's date/time format model (TO_CHAR / TO_VARCHAR
with a date format). Snowflake elements are translated to a
DateTimeFormatter pattern:
YYYY/YY/Y, MMMM/MON/MM, DD/DY/D, HH24/HH12/HH/H, MI, SS, FF[1-9], AM/PM, TZH/TZM pairs, TZD. The scan is greedy
longest-match at each position; any UNMATCHED character is emitted as a quoted literal, so
separators (-, /, :, spaces) pass through unchanged and unsupported elements degrade to literal
text rather than throwing. Snowflake has NO full-name 'DAY'/'MONTH' elements (live-verified on
DATE '2020-01-15'): 'DAY' tokenizes as D+A+Y — unpadded day-of-month, literal A, 2-digit year —
giving "15A20", and 'MONTH' as MON+T+H — "Jan", literal T, unpadded hour — giving "JanT0".
Month/day names use the English (US) locale in title case (e.g. "Jan", "January", "Wed"); the
format element's own case is not propagated to the output. TZH/TZM render the NTZ zero offset
("Z" for the pair). Not modeled: HH is treated as 24-hour, and era / quarter / week elements.-
Method Summary
Modifier and TypeMethodDescriptionstatic Stringstatic DateTimeFormatterformatterFor(String snowflakeFormat) ADateTimeFormatter(US locale) built from a Snowflake format string, usable for both formatting a temporal and parsing a string (TO_DATE / TO_TIMESTAMP with an explicit format).static booleanisDateFormat(String format) Whether the format string contains at least one recognized date/time element — used to decide whether a plain string value should be interpreted as a temporal (a DATE/TIMESTAMP value can reach a function as its ISO string) rather than a numeric or literal value.
-
Method Details
-
format
-
formatterFor
ADateTimeFormatter(US locale) built from a Snowflake format string, usable for both formatting a temporal and parsing a string (TO_DATE / TO_TIMESTAMP with an explicit format). Cached by the Snowflake format text. -
isDateFormat
Whether the format string contains at least one recognized date/time element — used to decide whether a plain string value should be interpreted as a temporal (a DATE/TIMESTAMP value can reach a function as its ISO string) rather than a numeric or literal value.
-