Class Utils

java.lang.Object
com.studerw.tda.parse.Utils

public class Utils extends Object
Helper class mainly for tests to pretty print JSON, dates, etc.
  • Field Details

  • Constructor Details

    • Utils

      public Utils()
  • Method Details

    • prettyFormat

      public static String prettyFormat(String input)
      Parameters:
      input - json
      Returns:
      formatted json (i.e. prettyPrint from Jackson)
    • epochToStr

      public static String epochToStr(Long epoch)
      Parameters:
      epoch - number of milliseconds since epoch
      Returns:
      formatted string e.g. January 25, 2019 at 3:55:06 AM CST
    • isNullOrEmpty

      public static boolean isNullOrEmpty(Collection<?> c)
      Parameters:
      c - collection to check if null or empty
      Returns:
      true if null or empty, otherwise false
    • isNullOrEmpty

      public static boolean isNullOrEmpty(Map<?,?> m)
      Parameters:
      m - map to check if null or empty
      Returns:
      true if null or empty, otherwise false
    • toTdaISO8601

      public static String toTdaISO8601(ZonedDateTime zonedDateTime)
      Parameters:
      zonedDateTime - the date to format
      Returns:
      a string formatted like yyyy-MM-dd'T'HH:mm:ssz.
    • fromTdaISO8601

      public static ZonedDateTime fromTdaISO8601(String isoString)
      Parameters:
      isoString - string formatted like yyyy-MM-dd'T'HH:mm:ssz.
      Returns:
      instant
    • toTdaYMD

      public static String toTdaYMD(ZonedDateTime zonedDateTime)
      Parameters:
      zonedDateTime - the date to format
      Returns:
      a string formatted like yyyy-MM-dd.
    • toTdaYMD

      public static String toTdaYMD(LocalDate localDate)
      Parameters:
      localDate - to convert
      Returns:
      a String in form of "yyyy-MM-dd"