Package ucar.nc2.units

Examples of ucar.nc2.units.TimeUnit


      return "time";
    } catch (Exception e) {
      // ok
    }

    SimpleUnit su = SimpleUnit.factory(unit);
    if (null == su) return "false";
    return su.getCanonicalString();
  }
View Full Code Here


   */
  private double getGridSpacingInKm(String type) {
    double value = gds.getDouble(type);
    if (Double.isNaN(value)) return value;
    String gridUnit = gds.getParam(GridDefRecord.GRID_UNITS);
    SimpleUnit unit = null;

    if (gridUnit == null || gridUnit.length() == 0) {
      unit = SimpleUnit.meterUnit;
    } else {
      unit = SimpleUnit.factory(gridUnit);
    }
    if (unit != null && SimpleUnit.isCompatible(unit.getUnitString(), "km")) {
      value = unit.convertTo(value, SimpleUnit.kmUnit);
    }
    return value;

  }
View Full Code Here

    } catch (Exception e) {
      // ok
    }

    try {
      new TimeUnit(unit);
      return "time";
    } catch (Exception e) {
      // ok
    }
View Full Code Here

   */
  public TimeUnit getTimeResolution() throws Exception {
    String tUnits = getUnitsString();
    StringTokenizer stoker = new StringTokenizer(tUnits);
    double tResolution = getIncrement();
    return new TimeUnit(tResolution, stoker.nextToken());
  }
View Full Code Here

  }

  private double getOlderThanFilter(List<MFileFilter> filters, String olderThan) {
    if (olderThan != null) {
      try {
        TimeUnit tu = new TimeUnit(olderThan);
        double olderThanV = tu.getValueInSeconds();
        filters.add( new LastModifiedLimit((long) (1000 * olderThanV)));
        return olderThanV;
      } catch (Exception e) {
        logger.error(collectionName + ": Invalid time unit for olderThan = {}", olderThan);
      }
View Full Code Here

  }

  private TimeUnit makeRecheck(String recheckS) {
    if (recheckS != null) {
      try {
        return new TimeUnit(recheckS);
      } catch (Exception e) {
        logger.error(collectionName+": Invalid time unit for recheckEvery = {}", recheckS);
      }
    }
    return null;
View Full Code Here

    else if (suffix != null)
      filters.add(new WildcardMatchOnPath("*" + suffix+"$"));

    if (olderS != null) {
      try {
        TimeUnit tu = new TimeUnit(olderS);
        filters.add(new LastModifiedLimit((long) (1000 * tu.getValueInSeconds())));
      } catch (Exception e) {
        logger.error(collectionName+": Invalid time unit for olderThan = {}", olderS);
      }
    }

View Full Code Here

      DateRange dateRange2 = gcs.getDateRange();
      if ((taxis != null) && ((dateRange == null) || !dateRange2.equals(dateRange))) {

        long ntimes = taxis.getSize();
        try {
          TimeUnit tUnit = taxis.getTimeResolution();
          dateRange = new DateRange(dateRange2, "1 hour");
          out.println("  DateRange == " + "start= " + dateRange.getStart() + " end= " + dateRange.getEnd() +
              " duration= " + dateRange.getDuration() + " ntimes = " + ntimes + " data resolution = " + tUnit);
        } catch (Exception e) {
          e.printStackTrace();
View Full Code Here

      String units = "Days ago";
      TimeDuration duration = dateRange.getDuration();
      double value = -0.0;

      try {
        TimeUnit tdayUnit = new TimeUnit("days");
        value = duration.getValue(tdayUnit);

      } catch (Exception e) {
        e.printStackTrace();
      }
View Full Code Here

    this.params.suffix = suffix;
    this.params.subdirs = subdirs != null && subdirs.equalsIgnoreCase("true");

    if (olderThanS != null) {
      try {
        TimeUnit tu = new TimeUnit(olderThanS);
        this.params.lastModifiedLimit  = (long) (1000 * tu.getValueInSeconds());
      } catch (Exception e) {
        logger.error("Invalid TimeUnit = "+olderThanS);
        throw new IllegalArgumentException("Invalid TimeUnit = "+olderThanS);
      }
    }
View Full Code Here

TOP

Related Classes of ucar.nc2.units.TimeUnit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.