Examples of TimeDuration


Examples of ucar.nc2.units.TimeDuration

  {
    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

Examples of ucar.nc2.units.TimeDuration

      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

Examples of ucar.nc2.units.TimeDuration

      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

Examples of ucar.nc2.units.TimeDuration

     //temporal
    DateRange tm = ds.getTimeCoverage();
    if (tm != null) {
      DateType end = tm.getEnd();
      if (end.isPresent()) {
        TimeDuration duration = tm.getDuration();
        double ndays = -duration.getValueInSeconds()/3600/24;
        String reletiveTime = "RELATIVE_START_DATE: "+((int)ndays);
        rootElem.addContent( new Element("Keyword", defNS).addContent(reletiveTime));
      }
    }
View Full Code Here

Examples of ucar.nc2.units.TimeDuration

    public static DateRange dateRangeToNcDateRange( ThreddsMetadata.DateRange dateRange )
            throws ParseException
    {
        DateType startDate = new DateType( dateRange.getStartDate(), dateRange.getStartDateFormat(), null );
        DateType endDate = new DateType( dateRange.getEndDate(), dateRange.getEndDateFormat(), null );
        return new DateRange( startDate, endDate, new TimeDuration( dateRange.getDuration()), null );
    }
View Full Code Here

Examples of ucar.nc2.units.TimeDuration

    public static DateRange dateRangeBuilderToNcDateRange( ThreddsMetadataBuilder.DateRangeBuilder dateRange )
            throws ParseException
    {
        DateType startDate = new DateType( dateRange.getStartDate(), dateRange.getStartDateFormat(), null );
        DateType endDate = new DateType( dateRange.getEndDate(), dateRange.getEndDateFormat(), null );
        return new DateRange( startDate, endDate, new TimeDuration( dateRange.getDuration()), null );
    }
View Full Code Here

Examples of ucar.nc2.units.TimeDuration

  protected TimeDuration readDuration(Element elem) {
    if (elem == null) return null;
    String text = null;
    try {
      text = elem.getText();
      return new TimeDuration( text);
    } catch (java.text.ParseException e) {
      factory.appendErr(" ** Parse error: Bad duration format = "+text+"\n");
      return null;
    }
  }
View Full Code Here

Examples of ucar.nc2.units.TimeDuration

  protected DateRange readTimeCoverage( Element tElem) {
    if (tElem == null) return null;

    DateType start = readDate( tElem.getChild("start", defNS));
    DateType end = readDate( tElem.getChild("end", defNS));
    TimeDuration duration = readDuration( tElem.getChild("duration", defNS));
    TimeDuration resolution = readDuration( tElem.getChild("resolution", defNS));

    try {
      DateRange tc = new DateRange( start, end, duration, resolution);
      return tc;
    } catch (java.lang.IllegalArgumentException e) {
View Full Code Here

Examples of ucar.nc2.units.TimeDuration

  protected Element writeTimeCoverage( DateRange t) {
    Element elem = new Element("timeCoverage", defNS);

    DateType start = t.getStart();
    DateType end = t.getEnd();
    TimeDuration duration = t.getDuration();
    TimeDuration resolution = t.getResolution();

    if (t.useStart() && (start != null) && !start.isBlank()) {
      Element startElem = new Element("start", defNS);
      startElem.setText(start.toString());
      elem.addContent(startElem);
    }

    if (t.useEnd() && (end != null) && !end.isBlank()) {
      Element telem = new Element("end", defNS);
      telem.setText(end.toString());
      elem.addContent(telem);
    }

    if (t.useDuration() && (duration != null) && !duration.isBlank()) {
      Element telem = new Element("duration", defNS);
      telem.setText(duration.toString());
      elem.addContent(telem);
    }

    if (t.useResolution() && (resolution != null) && !resolution.isBlank()) {
      Element telem = new Element("resolution", defNS);
      telem.setText(t.getResolution().toString());
      elem.addContent(telem);
    }
View Full Code Here

Examples of ucar.nc2.units.TimeDuration

    DateType startDate = dateRange.getStart();
    DateType endDate = dateRange.getEnd();
    if (endDate.isPresent()) {

      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
TOP
Copyright © 2018 www.massapi.com. 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.