Пример #1
0
  /**
   * using the time from the adapter to reset the time list
   *
   * @param realDateTimes _more_
   * @param times _more_
   * @return _more_
   */
  private List resetTimesList(DateTime[] realDateTimes, List<DateTime> times) {
    List results = new ArrayList();
    int len = realDateTimes.length;

    HashSet seenTimes = new HashSet();

    try {
      for (DateTime dateTime : times) {
        Date dttm = ucar.visad.Util.makeDate(dateTime);
        long minTimeDiff = -1;
        Date minDate = null;
        for (int i = 0; i < len; i++) {
          Date sourceDate = ucar.visad.Util.makeDate(realDateTimes[i]);
          long timeDiff = Math.abs(sourceDate.getTime() - dttm.getTime());
          if ((minTimeDiff < 0) || (timeDiff < minTimeDiff)) {
            minTimeDiff = timeDiff;
            minDate = sourceDate;
          }
        }
        if ((minDate != null) && !seenTimes.contains(minDate)) {
          results.add(new DateTime(minDate));
          seenTimes.add(minDate);
        }
      }
    } catch (Exception e) {
    }

    return results;
  }