Class ToCharUtil

java.lang.Object
com.gigaspaces.query.sql.functions.ToCharUtil

public class ToCharUtil extends Object
Emulates Oracle's TO_CHAR function.
  • Method Details

    • toChar

      public static String toChar(BigDecimal number, String format, String nlsParam)
      Emulates Oracle's TO_CHAR(number) function.

      InputOutputClosest DecimalFormat Equivalent
      ,Grouping separator.,
      .Decimal separator..
      $Leading dollar sign.$
      0Leading or trailing zeroes.0
      9Digit.#
      BBlanks integer part of a fixed point number less than 1.#
      CISO currency symbol.¤
      DLocal decimal separator..
      EEEEReturns a value in scientific notation.E
      FMReturns values with no leading or trailing spaces.None.
      GLocal grouping separator.,
      LLocal currency symbol.¤
      MINegative values get trailing minus sign, positive get trailing space.-
      PRNegative values get enclosing angle brackets, positive get spaces.None.
      RNReturns values in Roman numerals.None.
      SReturns values with leading/trailing +/- signs.None.
      TMReturns smallest number of characters possible.None.
      UReturns the dual currency symbol.None.
      VReturns a value multiplied by 10^n.None.
      XHex value.None.
      See also TO_CHAR(number) and number format models in the Oracle documentation.
      Parameters:
      number - the number to format
      format - the format pattern to use (if any)
      nlsParam - the NLS parameter (if any)
      Returns:
      the formatted number
    • toChar

      public static String toChar(Timestamp ts, String format, String nlsParam)
      Emulates Oracle's TO_CHAR(datetime) function.

      InputOutputClosest SimpleDateFormat Equivalent
      - / , . ; : "text"Reproduced verbatim.'text'
      A.D. AD B.C. BCEra designator, with or without periods.G
      A.M. AM P.M. PMAM/PM marker.a
      CC SCCCentury.None.
      DDay of week.u
      DAYName of day.EEEE
      DYAbbreviated day name.EEE
      DDDay of month.d
      DDDDay of year.D
      DLLong date format.EEEE, MMMM d, yyyy
      DSShort date format.MM/dd/yyyy
      EAbbreviated era name (Japanese, Chinese, Thai)None.
      EEFull era name (Japanese, Chinese, Thai)None.
      FF[1-9]Fractional seconds.S
      FMReturns values with no leading or trailing spaces.None.
      FXRequires exact matches between character data and format model.None.
      HH HH12Hour in AM/PM (1-12).hh
      HH24Hour in day (0-23).HH
      IWWeek in year.w
      WWWeek in year.w
      WWeek in month.W
      IYYY IYY IY ILast 4/3/2/1 digit(s) of ISO year.yyyy yyy yy y
      RRRR RRLast 4/2 digits of year.yyyy yy
      Y,YYYYear with comma.None.
      YEAR SYEARYear spelled out (S prefixes BC years with minus sign).None.
      YYYY SYYYY4-digit year (S prefixes BC years with minus sign).yyyy
      YYY YY YLast 3/2/1 digit(s) of year.yyy yy y
      JJulian day (number of days since January 1, 4712 BC).None.
      MIMinute in hour.mm
      MMMonth in year.MM
      MONAbbreviated name of month.MMM
      MONTHName of month, padded with spaces.MMMM
      RMRoman numeral month.None.
      QQuarter of year.None.
      SSSeconds in minute.ss
      SSSSSSeconds in day.None.
      TSShort time format.h:mm:ss aa
      TZDDaylight savings time zone abbreviation.z
      TZRTime zone region information.zzzz
      XLocal radix character.None.

      See also TO_CHAR(datetime) and datetime format models in the Oracle documentation.

      Parameters:
      ts - the timestamp to format
      format - the format pattern to use (if any)
      nlsParam - the NLS parameter (if any)
      Returns:
      the formatted timestamp