code: public static String getTimeRangeString(Date fromDate, Date toDate) {
          if (fromDate == null && toDate == null) {
              return null;
          }
  
          StringBuilder sbr = new StringBuilder();
          if (fromDate != null) {
              sbr.append(format(fromDate));
          }
          sbr.append(",");
          if (toDate != null) {
              sbr.append(format(toDate));
          }
          return sbr.toString();
      }
docs: Get a String to represent a time range.
  
  @param fromDate can use null if don't want to specify this.
  @param toDate can use null if don't want to specify this.
  @return The string will be time strings separated by a comma.
  Trailing "from_date," and leading ",to_date" are also accepted if one of the date is null.
  Returns null if both dates are null.