Class ConvertTimezone

java.lang.Object
dev.frostlake.functions.BuiltInFunction
dev.frostlake.functions.scalar.datetime.ConvertTimezone

public class ConvertTimezone extends BuiltInFunction
  • Constructor Details

    • ConvertTimezone

      public ConvertTimezone()
  • Method Details

    • evaluate

      public Object evaluate(List<Object> args)
      ★ THE TWO ARITIES ARE TWO FUNCTIONS. The THREE-argument form names the source zone itself, so its input is a wall clock and its answer is one — a TIMESTAMP_NTZ, which is what this declares. The TWO-argument form takes an INSTANT and re-expresses it in the named zone, so its answer carries that zone's offset and is a TIMESTAMP_TZ: live gives 2020-01-02 03:00:00.000 +0900 for an Asia/Tokyo conversion, not the session's offset.

      Frostlake read the value's wall clock and re-labelled it UTC, which converted nothing at all — the two-argument form handed its input straight back.

      Specified by:
      evaluate in class BuiltInFunction
      Parameters:
      args - the target zone and the value, or the source zone, the target zone and the value
      Returns:
      the converted timestamp, or null when the value is null
    • getMinArgCount

      public int getMinArgCount()
      Description copied from class: BuiltInFunction
      The fewest arguments a call to this function may pass; fewer is an argument-count error.
      Specified by:
      getMinArgCount in class BuiltInFunction
      Returns:
      the minimum accepted argument count
    • getMaxArgCount

      public int getMaxArgCount()
      Description copied from class: BuiltInFunction
      The most arguments a call to this function may pass; Integer.MAX_VALUE marks a variadic function (see BuiltInFunction.isVariadic()).
      Specified by:
      getMaxArgCount in class BuiltInFunction
      Returns:
      the maximum accepted argument count