public class ResultUtil extends Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_SCALE_OF_SFTIME_FRACTION_SECONDS |
static int |
MILLIS_IN_ONE_DAY |
Constructor and Description |
---|
ResultUtil() |
Modifier and Type | Method and Description |
---|---|
static Date |
adjustDate(Date date)
Adjust date for before 1582-10-05
|
static Timestamp |
adjustTimestamp(Timestamp timestamp)
Adjust timestamp for dates before 1582-10-05
|
static long |
calculateUpdateCount(SFBaseResultSet resultSet)
Calculate number of rows updated given a result set Interpret result format based on result
set's statement type
|
static Object |
effectiveParamValue(Map<String,Object> parameters,
String paramName)
Returns the effective parameter value, using the value explicitly provided in parameters, or
the default if absent
|
static boolean |
getBoolean(String str)
Convert snowflake bool to java boolean
|
static String |
getBooleanAsString(boolean bool)
Convert a boolean to a string
|
static List<SFChildResult> |
getChildResults(SFSession session,
String requestId,
com.fasterxml.jackson.databind.JsonNode result)
Return the list of child results provided in a result, if available; otherwise return an empty
list
|
static Date |
getDate(String str,
TimeZone tz,
SFSession session)
Deprecated.
|
static String |
getDateAsString(Date date,
net.snowflake.common.core.SnowflakeDateTimeFormat dateFormatter)
Convert a date value into a string
|
static net.snowflake.common.core.SFTime |
getSFTime(String obj,
int scale,
SFSession session)
Convert a time internal value (scaled number of seconds + fractional seconds) into an SFTime.
|
static String |
getSFTimeAsString(net.snowflake.common.core.SFTime sft,
int scale,
net.snowflake.common.core.SnowflakeDateTimeFormat timeFormatter)
Convert a time value into a string
|
static net.snowflake.common.core.SFTimestamp |
getSFTimestamp(String timestampStr,
int scale,
int internalColumnType,
long resultVersion,
TimeZone sessionTZ,
SFSession session)
Convert a timestamp internal value (scaled number of seconds + fractional seconds) into a
SFTimestamp.
|
static String |
getSFTimestampAsString(net.snowflake.common.core.SFTimestamp sfTS,
int columnType,
int scale,
net.snowflake.common.core.SnowflakeDateTimeFormat timestampNTZFormatter,
net.snowflake.common.core.SnowflakeDateTimeFormat timestampLTZFormatter,
net.snowflake.common.core.SnowflakeDateTimeFormat timestampTZFormatter,
SFSession session)
Convert a SFTimestamp to a string value.
|
static int |
listSearchCaseInsensitive(List<String> source,
String target)
Given a list of String, do a case insensitive search for target string Used by
resultsetMetadata to search for target column name
|
static long |
msDiffJulianToGregorian(Date date)
For dates before 1582-10-05, calculate the number of millis to adjust.
|
static net.snowflake.common.core.SnowflakeDateTimeFormat |
specializedFormatter(Map<String,Object> parameters,
String id,
String param,
String defaultFormat)
Helper function building a formatter for a specialized timestamp type.
|
public static final int MILLIS_IN_ONE_DAY
public static final int DEFAULT_SCALE_OF_SFTIME_FRACTION_SECONDS
public static Object effectiveParamValue(Map<String,Object> parameters, String paramName)
parameters
- keyed in parameter name and valued in parameter valueparamName
- Parameter to return the value ofpublic static net.snowflake.common.core.SnowflakeDateTimeFormat specializedFormatter(Map<String,Object> parameters, String id, String param, String defaultFormat)
public static Timestamp adjustTimestamp(Timestamp timestamp)
timestamp
- needs to be adjustedpublic static long msDiffJulianToGregorian(Date date)
date
- date before 1582-10-05public static net.snowflake.common.core.SFTimestamp getSFTimestamp(String timestampStr, int scale, int internalColumnType, long resultVersion, TimeZone sessionTZ, SFSession session) throws SFException
timestampStr
- timestamp objectscale
- timestamp scaleinternalColumnType
- snowflake timestamp typeresultVersion
- For new result version, timestamp with timezone is formatted as the
seconds since epoch with fractional part in the decimal followed by time zone index. E.g.:
"123.456 1440". Here 123.456 is the * number of seconds since epoch and 1440 is the
timezone index.sessionTZ
- session timezonesession
- session objectSFException
- if timestampStr is an invalid timestamppublic static net.snowflake.common.core.SFTime getSFTime(String obj, int scale, SFSession session) throws SFException
Example: getSFTime("123.456", 5) returns an SFTime for 00:02:03.45600.
obj
- time objectscale
- time scalesession
- session objectSFException
- if time is invalidpublic static String getSFTimeAsString(net.snowflake.common.core.SFTime sft, int scale, net.snowflake.common.core.SnowflakeDateTimeFormat timeFormatter)
sft
- snowflake time objectscale
- time scaletimeFormatter
- time formatterpublic static String getBooleanAsString(boolean bool)
bool
- booleanpublic static String getSFTimestampAsString(net.snowflake.common.core.SFTimestamp sfTS, int columnType, int scale, net.snowflake.common.core.SnowflakeDateTimeFormat timestampNTZFormatter, net.snowflake.common.core.SnowflakeDateTimeFormat timestampLTZFormatter, net.snowflake.common.core.SnowflakeDateTimeFormat timestampTZFormatter, SFSession session) throws SFException
sfTS
- snowflake timestamp objectcolumnType
- internal snowflake tscale
- timestamp scaletimestampNTZFormatter
- snowflake timestamp ntz formattimestampLTZFormatter
- snowflake timestamp ltz formattimestampTZFormatter
- snowflake timestamp tz formatsession
- session objectSFException
- timestamp format is missingpublic static String getDateAsString(Date date, net.snowflake.common.core.SnowflakeDateTimeFormat dateFormatter)
date
- date will be converteddateFormatter
- date formatpublic static Date adjustDate(Date date)
date
- date before 1582-10-05@Deprecated public static Date getDate(String str, TimeZone tz, SFSession session) throws SFException
str
- snowflake date objecttz
- timezone we want convert tosession
- snowflake session objectSFException
- if date is invalidpublic static boolean getBoolean(String str)
str
- boolean type in string representationpublic static long calculateUpdateCount(SFBaseResultSet resultSet) throws SFException, SQLException
resultSet
- result set to extract update count fromSFException
- if failed to calculate update countSQLException
- if failed to calculate update countpublic static int listSearchCaseInsensitive(List<String> source, String target)
source
- source string listtarget
- target string to matchpublic static List<SFChildResult> getChildResults(SFSession session, String requestId, com.fasterxml.jackson.databind.JsonNode result) throws SFException
session
- the current sessionrequestId
- the current request idresult
- result jsonSFException
- if the number of child IDs does not match child statement typesCopyright © 2020. All rights reserved.