Package ucar.nc2.units

Examples of ucar.nc2.units.TimeDuration


      boundingBox = geoCoverage.getBoundingBox();
    else // otherwise, stationHelper constructs from the station locations
      boundingBox = stationHelper.getBoundingBox();

    // get the date range if possible
    DateRange timeCoverage = invds.getTimeCoverage();
    if (timeCoverage != null) {
      startDate = timeCoverage.getStart().getDate();
      endDate = timeCoverage.getEnd().getDate();
    } else {
      startDate = new Date(0); // fake
      endDate = new Date();
    }
View Full Code Here


    Attribute versionAtt = startElement.getAttributeByName( CatalogElementNames.CatalogElement_Version );
    String versionString = versionAtt != null ? versionAtt.getValue() : null;
    Attribute expiresAtt = startElement.getAttributeByName( CatalogElementNames.CatalogElement_Expires );
    String expiresString = expiresAtt != null ? expiresAtt.getValue() : null;
    DateType expires = null;
    try {
      expires = expiresString != null ? new DateType( expiresString, null, null ) : null;
    }
    catch ( ParseException e )
    {
      String msg = "Failed to parse catalog expires date [" + expiresString + "].";
      ThreddsXmlParserIssue issue = StaxThreddsXmlParserUtils.createIssueForException( msg, this.reader, e );
      log.warn( "parseStartElement(): " + issue.getMessage(), e );
      // ToDo Gather issues rather than throw exception.
      throw new ThreddsXmlParserException( issue );
    }
    Attribute lastModifiedAtt = startElement.getAttributeByName( CatalogElementNames.CatalogElement_LastModified );
    String lastModifiedString = lastModifiedAtt != null ? lastModifiedAtt.getValue() : null;
    DateType lastModified = null;
    try {
      lastModified = lastModifiedString != null ? new DateType( lastModifiedString, null, null ) : null;
    }
    catch ( ParseException e )
    {
      String msg = "Failed to parse catalog lastModified date [" + lastModifiedString + "].";
      ThreddsXmlParserIssue issue = StaxThreddsXmlParserUtils.createIssueForException( msg, this.reader, e );
View Full Code Here

      Variable time = ds.findVariable("time_offset");
      if (time != null) {
        Variable base = ds.findVariable("base_time");
        int base_time = base.readScalarInt();
        try {
          DateUnit dunit = new DateUnit("seconds since 1970-01-01 00:00");
          String time_units = "seconds since " + dunit.makeStandardDateString(base_time);
          time.addAttribute(new Attribute("units", time_units));
          time.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Time.name()));
        } catch (Exception e) {
          e.printStackTrace();
        }
View Full Code Here

    return " ";
  }

private String isUdunits(String unit) {
    try {
      new DateUnit(unit);
      return "date";
    } catch (Exception e) {
      // ok
    }
View Full Code Here

                uStart = description.lastIndexOf("(");
                if (uStart >= 0 && uEnd > uStart) {
                    String possibleUnitName = description.substring(uStart
                                                  + 1, uEnd);
                    try {
                        SimpleUnit u = SimpleUnit.factoryWithExceptions(
                                           possibleUnitName);
                        unitName = possibleUnitName;
                    } catch (Exception e) {
                        unitName = null;
                    }
View Full Code Here

      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

  {
    this.catName = "Catalog Name";
    this.catDocBaseUri = new URI( "http://server/thredds/cat.xml");
    this.catVersion = "1.0.2";
    this.catLastModified = new DateType( false, new Date( System.currentTimeMillis() ) );
    this.catExpires = new DateType( catLastModified ).add( new TimeDuration( "P5D" ) );
    this.catLastModified2 = this.catLastModified.add( new TimeDuration( "P1D"));
    this.catExpires2 = this.catLastModified2.add( new TimeDuration( "P5D"));
    this.catImpl = new CatalogImpl( catName, catDocBaseUri, this.catVersion, this.catExpires, this.catLastModified);

    try
    { baseUri = new URI( "http://server/thredds/dodsC/" );
      docBaseUri = new URI( "http://server/thredds/aCat.xml" ); }
View Full Code Here

      try
      {
        ((InvDatasetImpl) dataset).setTimeCoverage(
                new DateRange( new DateType( startTime.toString(), null, null), null,
                               new TimeDuration( this.duration ), null ) );
      }
      catch ( ParseException e )
      {
        logger.debug( "Start time <" + startTime.toString() + "> or duration <" + this.duration + "> not parsable: " + e.getMessage());
        return( false);
View Full Code Here

      Date start = format.getISODate(beginS);
      Date end = format.getISODate(endS);
      DateRange dr = new DateRange(start, end);
     
      if (resS != null)
        dr.setResolution(new TimeDuration(resS));

      return dr;

    } catch (Exception e) {
      return null;
View Full Code Here

TOP

Related Classes of ucar.nc2.units.TimeDuration

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.